Zelda Classic Coverage Report


Directory: src/
File: src/qst.cpp
Date: 2023-10-28 10:17:38
Exec Total Coverage
Lines: 8515 12493 68.2%
Functions: 93 128 72.7%
Branches: 5679 10587 53.6%

Line Branch Exec Source
1 #include "allegro/file.h"
2 #include "base/util.h"
3 #include "base/zapp.h"
4 #include "base/qrs.h"
5 #include "base/cpool.h"
6 #include "base/autocombo.h"
7 #include "base/packfile.h"
8 #include "base/dmap.h"
9 #include "base/combo.h"
10 #include "base/msgstr.h"
11 #include <filesystem>
12 #include <stdio.h>
13 #include <cstring>
14 #include <string>
15 #include <map>
16 #include <vector>
17 #include <assert.h>
18 #include <fmt/format.h>
19
20
21 #include "metadata/sigs/devsig.h.sig"
22 #include "metadata/sigs/compilersig.h.sig"
23 #include "metadata/versionsig.h"
24 #include "base/zc_alleg.h"
25 #include "base/zdefs.h"
26 #include "base/colors.h"
27 #include "tiles.h"
28 #include "base/zsys.h"
29 #include "qst.h"
30 #include "defdata.h"
31 #include "subscr.h"
32 #include "zc/replay.h"
33 #include "zc/zc_custom.h"
34 #include "sfx.h"
35 #include "md5.h"
36 #include "zinfo.h"
37 #include "zc/ffscript.h"
38 #include "particles.h"
39 #include "dialog/alert.h"
40 #include "base/misctypes.h"
41 #include "base/initdata.h"
42
43 //FFScript FFCore;
44 extern FFScript FFCore;
45 extern ZModule zcm;
46 extern zcmodule moduledata;
47 extern uint8_t __isZQuest;
48 extern sprite_list guys, items, Ewpns, Lwpns, chainlinks, decorations;
49 extern particle_list particles;
50 extern void setZScriptVersion(int32_t s_version);
51 //FFSCript FFEngine;
52
53 static bool read_ext_zinfo = false, read_zinfo = false;
54 static bool loadquest_report = false;
55 static char const* loading_qst_name = NULL;
56 static byte loading_qst_num = 0;
57 static byte subscr_mode = ssdtMAX;
58 dword loading_tileset_flags = 0;
59
60 int32_t First[MAX_COMBO_COLS]={0},combo_alistpos[MAX_COMBO_COLS]={0},combo_pool_listpos[MAX_COMBO_COLS]={0},combo_auto_listpos[MAX_COMBO_COLS]={0};
61 map_and_screen map_page[MAX_MAPPAGE_BTNS]= {{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}};
62
63 #ifdef _MSC_VER
64 #define strncasecmp _strnicmp
65 #endif
66
67 #ifndef _AL_MALLOC
68 #define _AL_MALLOC(a) _al_malloc(a)
69 #define _AL_FREE(a) _al_free(a)
70 #endif
71
72 using std::string;
73 using std::pair;
74
75 // extern bool debug;
76 extern int32_t hero_animation_speed; //lower is faster animation
77 extern byte *colordata;
78 //extern byte *tilebuf;
79 extern tiledata *newtilebuf;
80 extern byte *trashbuf;
81 extern itemdata *itemsbuf;
82 extern wpndata *wpnsbuf;
83 extern comboclass *combo_class_buf;
84 extern guydata *guysbuf;
85 extern ZCHEATS zcheats;
86 extern char palnames[MAXLEVELS][17];
87 extern int32_t memrequested;
88 extern char *byte_conversion(int32_t number, int32_t format);
89 extern char *byte_conversion2(int32_t number1, int32_t number2, int32_t format1, int32_t format2);
90 string zScript;
91 114 std::map<int32_t, script_slot_data > ffcmap;
92 114 std::map<int32_t, script_slot_data > globalmap;
93 114 std::map<int32_t, script_slot_data > genericmap;
94 114 std::map<int32_t, script_slot_data > itemmap;
95 114 std::map<int32_t, script_slot_data > npcmap;
96 114 std::map<int32_t, script_slot_data > ewpnmap;
97 114 std::map<int32_t, script_slot_data > lwpnmap;
98 114 std::map<int32_t, script_slot_data > playermap;
99 114 std::map<int32_t, script_slot_data > dmapmap;
100 114 std::map<int32_t, script_slot_data > screenmap;
101 114 std::map<int32_t, script_slot_data > itemspritemap;
102 114 std::map<int32_t, script_slot_data > comboscriptmap;
103 114 std::map<int32_t, script_slot_data > subscreenmap;
104 void free_newtilebuf();
105 bool combosread=false;
106 bool mapsread=false;
107 bool fixffcs=false;
108 bool fixpolsvoice=false;
109
110 const std::string script_slot_data::DEFAULT_FORMAT = "%s %s";
111 const std::string script_slot_data::INVALID_FORMAT = "%s --%s";
112 const std::string script_slot_data::DISASSEMBLED_FORMAT = "%s ++%s";
113 const std::string script_slot_data::ZASM_FORMAT = "%s ==%s";
114
115 char qstdat_string[2048] = { 0 };
116
117 static zinfo* load_tmp_zi = NULL;
118
119 int32_t memDBGwatch[8]= {0,0,0,0,0,0,0,0}; //So I can monitor memory crap
120 const byte clavio[9]={97,109,111,110,103,117,115,0};
121
122 //enum { qe_OK, qe_notfound, qe_invalid, qe_version, qe_obsolete,
123 // qe_missing, qe_internal, qe_pwd, qe_match, qe_minver };
124
125 const char *qst_error[] =
126 {
127 "OK","File not found","Invalid quest file",
128 "Version not supported","Obsolete version",
129 "Missing new data" , /* but let it pass in ZQuest */
130 "Internal error occurred", "Invalid password",
131 "Doesn't match saved game", "Save file is for older version of quest; please start new save",
132 "Out of memory", "File Debug Mode", "Canceled", "", "No quest assigned"
133 };
134
135 //for legacy quests -DD
136 enum { ssiBOMB, ssiSWORD, ssiSHIELD, ssiCANDLE, ssiLETTER, ssiPOTION, ssiLETTERPOTION, ssiBOW, ssiARROW, ssiBOWANDARROW, ssiBAIT, ssiRING, ssiBRACELET, ssiMAP,
137 ssiCOMPASS, ssiBOSSKEY, ssiMAGICKEY, ssiBRANG, ssiWAND, ssiRAFT, ssiLADDER, ssiWHISTLE, ssiBOOK, ssiWALLET, ssiSBOMB, ssiHCPIECE, ssiAMULET, ssiFLIPPERS,
138 ssiHOOKSHOT, ssiLENS, ssiHAMMER, ssiBOOTS, ssiDIVINEFIRE, ssiDIVINEESCAPE, ssiDIVINEPROTECTION, ssiQUIVER, ssiBOMBBAG, ssiCBYRNA, ssiROCS, ssiHOVERBOOTS,
139 ssiSPINSCROLL, ssiCROSSSCROLL, ssiQUAKESCROLL, ssiWHISPRING, ssiCHARGERING, ssiPERILSCROLL, ssiWEALTHMEDAL, ssiHEARTRING, ssiMAGICRING, ssiSPINSCROLL2,
140 ssiQUAKESCROLL2, ssiAGONY, ssiSTOMPBOOTS, ssiWHIMSICALRING, ssiPERILRING, ssiMAX
141 };
142
143 static byte deprecated_rules[QUESTRULES_NEW_SIZE];
144
145
146 void delete_combo_aliases()
147 {
148 for(int32_t j(0); j<256; j++)
149 {
150 if(combo_aliases[j].combos != NULL)
151 {
152 delete[] combo_aliases[j].combos;
153 combo_aliases[j].combos=NULL;
154 }
155
156 if(combo_aliases[j].csets != NULL)
157 {
158 delete[] combo_aliases[j].csets;
159 combo_aliases[j].csets=NULL;
160 }
161 }
162
163 }
164
165 char *byte_conversion(int32_t number, int32_t format)
166 {
167 static char num_str[40];
168
169 if(format==-1) //auto
170 {
171 format=1; //bytes
172
173 if(number>1024)
174 {
175 format=2; //kilobytes
176 }
177
178 if(number>1024*1024)
179 {
180 format=3; //megabytes
181 }
182
183 if(number>1024*1024*1024)
184 {
185 format=4; //gigabytes (dude, what are you doing?)
186 }
187 }
188
189 switch(format)
190 {
191 case 1: //bytes
192 sprintf(num_str,"%db",number);
193 break;
194
195 case 2: //kilobytes
196 sprintf(num_str,"%.2fk",float(number)/1024);
197 break;
198
199 case 3: //megabytes
200 sprintf(num_str,"%.2fM",float(number)/(1024*1024));
201 break;
202
203 case 4: //gigabytes
204 sprintf(num_str,"%.2fG",float(number)/(1024*1024*1024));
205 break;
206
207 default:
208 abort();
209 break;
210 }
211
212 return num_str;
213 }
214
215 1368 char *byte_conversion2(int32_t number1, int32_t number2, int32_t format1, int32_t format2)
216 {
217 static char num_str1[40];
218 static char num_str2[40];
219 static char num_str[80];
220
221
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1368 times.
1368 if(format1==-1) //auto
222 {
223 1368 format1=1; //bytes
224
225
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1368 times.
1368 if(number1>1024)
226 {
227 1368 format1=2; //kilobytes
228 1368 }
229
230
2/2
✓ Branch 0 taken 912 times.
✓ Branch 1 taken 456 times.
1368 if(number1>1024*1024)
231 {
232 456 format1=3; //megabytes
233 456 }
234
235
1/2
✓ Branch 0 taken 1368 times.
✗ Branch 1 not taken.
1368 if(number1>1024*1024*1024)
236 {
237 format1=4; //gigabytes (dude, what are you doing?)
238 }
239 1368 }
240
241
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1368 times.
1368 if(format2==-1) //auto
242 {
243 1368 format2=1; //bytes
244
245
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1368 times.
1368 if(number2>1024)
246 {
247 1368 format2=2; //kilobytes
248 1368 }
249
250
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1368 times.
1368 if(number2>1024*1024)
251 {
252 1368 format2=3; //megabytes
253 1368 }
254
255
1/2
✓ Branch 0 taken 1368 times.
✗ Branch 1 not taken.
1368 if(number2>1024*1024*1024)
256 {
257 format2=4; //gigabytes (dude, what are you doing?)
258 }
259 1368 }
260
261
2/5
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 912 times.
✓ Branch 3 taken 456 times.
✗ Branch 4 not taken.
1368 switch(format1)
262 {
263 case 1: //bytes
264 sprintf(num_str1,"%db",number1);
265 break;
266
267 case 2: //kilobytes
268 912 sprintf(num_str1,"%.2fk",float(number1)/1024);
269 912 break;
270
271 case 3: //megabytes
272 456 sprintf(num_str1,"%.2fM",float(number1)/(1024*1024));
273 456 break;
274
275 case 4: //gigabytes
276 sprintf(num_str1,"%.2fG",float(number1)/(1024*1024*1024));
277 break;
278
279 default:
280 abort();
281 break;
282 }
283
284
1/5
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1368 times.
✗ Branch 4 not taken.
1368 switch(format2)
285 {
286 case 1: //bytes
287 sprintf(num_str2,"%db",number2);
288 break;
289
290 case 2: //kilobytes
291 sprintf(num_str2,"%.2fk",float(number2)/1024);
292 break;
293
294 case 3: //megabytes
295 1368 sprintf(num_str2,"%.2fM",float(number2)/(1024*1024));
296 1368 break;
297
298 case 4: //gigabytes
299 sprintf(num_str2,"%.2fG",float(number2)/(1024*1024*1024));
300 break;
301
302 default:
303 abort();
304 break;
305 }
306
307 1368 sprintf(num_str, "%s/%s", num_str1, num_str2);
308 1368 return num_str;
309 }
310
311 char *ordinal(int32_t num)
312 {
313 static const char *ending[4] = {"st","nd","rd","th"};
314 static char ord_str[8];
315
316 char *end;
317 int32_t t=(num%100)/10;
318 int32_t n=num%10;
319
320 if(n>=1 && n<4 && t!=1)
321 end = (char *)ending[n-1];
322 else
323 end = (char *)ending[3];
324
325 sprintf(ord_str,"%d%s",num%10000,end);
326 return ord_str;
327 }
328
329 int32_t get_version_and_build(PACKFILE *f, word *version, word *build)
330 {
331 int32_t ret;
332 *version=0;
333 *build=0;
334 byte temp_map_count=map_count;
335 byte temp_midi_flags[MIDIFLAGS_SIZE];
336 memcpy(temp_midi_flags, midi_flags, MIDIFLAGS_SIZE);
337
338 zquestheader tempheader;
339
340 if(!f)
341 {
342 return qe_invalid;
343 }
344
345 ret=readheader(f, &tempheader);
346
347 if(ret)
348 {
349 return ret;
350 }
351
352 map_count=temp_map_count;
353 memcpy(midi_flags, temp_midi_flags, MIDIFLAGS_SIZE);
354 *version=tempheader.zelda_version;
355 *build=tempheader.build;
356 return 0;
357 }
358
359
360 bool find_section(PACKFILE *f, int32_t section_id_requested)
361 {
362
363 if(!f)
364 {
365 return false;
366 }
367
368 int32_t section_id_read;
369 bool catchup=false;
370 word dummy;
371 byte tempbyte;
372 char tempbuf[65536];
373
374
375 switch(section_id_requested)
376 {
377 case ID_RULES:
378 case ID_STRINGS:
379 case ID_MISC:
380 case ID_TILES:
381 case ID_COMBOS:
382 case ID_CSETS:
383 case ID_MAPS:
384 case ID_DMAPS:
385 case ID_DOORS:
386 case ID_ITEMS:
387 case ID_WEAPONS:
388 case ID_COLORS:
389 case ID_ICONS:
390 case ID_INITDATA:
391 case ID_GUYS:
392 case ID_MIDIS:
393 case ID_CHEATS:
394 break;
395
396 default:
397 al_trace("Bad section requested!\n");
398 return false;
399 break;
400 }
401
402 dword section_size;
403
404 //section id
405 if(!p_mgetl(&section_id_read,f))
406 {
407 return false;
408 }
409
410 while(!pack_feof(f))
411 {
412 switch(section_id_read)
413 {
414 case ID_RULES:
415 case ID_STRINGS:
416 case ID_MISC:
417 case ID_TILES:
418 case ID_COMBOS:
419 case ID_CSETS:
420 case ID_MAPS:
421 case ID_DMAPS:
422 case ID_DOORS:
423 case ID_ITEMS:
424 case ID_WEAPONS:
425 case ID_COLORS:
426 case ID_ICONS:
427 case ID_INITDATA:
428 case ID_GUYS:
429 case ID_MIDIS:
430 case ID_CHEATS:
431 catchup=false;
432 break;
433
434 default:
435 break;
436 }
437
438
439 while(catchup)
440 {
441 //section id
442 section_id_read=(section_id_read<<8);
443
444 if(!p_getc(&tempbyte,f))
445 {
446 return false;
447 }
448
449 section_id_read+=tempbyte;
450 }
451
452 if(section_id_read==section_id_requested)
453 {
454 return true;
455 }
456 else
457 {
458 //section version info
459 if(!p_igetw(&dummy,f))
460 {
461 return false;
462 }
463
464 if(!p_igetw(&dummy,f))
465 {
466 return false;
467 }
468
469 //section size
470 if(!p_igetl(&section_size,f))
471 {
472 return false;
473 }
474
475 //pack_fseek(f, section_size);
476 while(section_size>65535)
477 {
478 pfread(tempbuf,65535,f);
479 tempbuf[65535]=0;
480 section_size-=65535;
481 }
482
483 if(section_size>0)
484 {
485 pfread(tempbuf,section_size,f);
486 tempbuf[section_size]=0;
487 }
488 }
489
490 //section id
491 if(!p_mgetl(&section_id_read,f))
492 {
493 return false;
494 }
495 }
496
497 return false;
498 }
499
500
501
502
503
504 bool valid_zqt(PACKFILE *f)
505 {
506
507 //word tiles_used;
508 //word combos_used;
509 //open the file
510 //PACKFILE *f = pack_fopen(path, F_READ_PACKED);
511 if(!f)
512 return false;
513
514 //for now, everything else is valid
515 return true;
516
517 /*int16_t version;
518 byte build;
519
520 //read the version and make sure it worked
521 if(!p_igetw(&version,f))
522 {
523 goto error;
524 }
525
526 //read the build and make sure it worked
527 if(!p_getc(&build,f))
528 goto error;
529
530 //read the tile info and make sure it worked
531 if(!p_igetw(&tiles_used,f))
532 {
533 goto error;
534 }
535
536 for (int32_t i=0; i<tiles_used; i++)
537 {
538 if(!pfread(trashbuf,tilesize(tf4Bit),f))
539 {
540 goto error;
541 }
542 }
543
544 //read the combo info and make sure it worked
545 if(!p_igetw(&combos_used,f))
546 {
547 goto error;
548 }
549 for (int32_t i=0; i<combos_used; i++)
550 {
551 if(!pfread(trashbuf,sizeof(newcombo),f))
552 {
553 goto error;
554 }
555 }
556
557 //read the palette info and make sure it worked
558 for (int32_t i=0; i<48; i++)
559 {
560 if(!pfread(trashbuf,newpdTOTAL,f))
561 {
562 goto error;
563 }
564 }
565 if(!pfread(trashbuf,sizeof(palcycle)*256*3,f))
566 {
567 goto error;
568 }
569 for (int32_t i=0; i<MAXLEVELS; i++)
570 {
571 if(!pfread(trashbuf,PALNAMESIZE,f))
572 {
573 goto error;
574 }
575 }
576
577 //read the sprite info and make sure it worked
578 for (int32_t i=0; i<MAXITEMS; i++)
579 {
580 if(!pfread(trashbuf,sizeof(itemdata),f))
581 {
582 goto error;
583 }
584 }
585
586 for (int32_t i=0; i<MAXWPNS; i++)
587 {
588 if(!pfread(trashbuf,sizeof(wpndata),f))
589 {
590 goto error;
591 }
592 }
593
594 //read the triforce pieces info and make sure it worked
595 for (int32_t i=0; i<8; ++i)
596 {
597 if(!p_getc(&trashbuf,f))
598 {
599 goto error;
600 }
601 }
602
603
604
605 //read the game icons info and make sure it worked
606 for (int32_t i=0; i<4; ++i)
607 {
608 if(!p_igetw(&trashbuf,f))
609 {
610 goto error;
611 }
612 }
613
614 //read the misc colors info and map styles info and make sure it worked
615 if(!pfread(trashbuf,sizeof(zcolors),f))
616 {
617 goto error;
618 }
619
620 //read the template screens and make sure it worked
621 byte num_maps;
622 if(!p_getc(&num_maps,f))
623 {
624 goto error;
625 }
626 for (int32_t i=0; i<TEMPLATES; i++)
627 {
628 if(!pfread(trashbuf,sizeof(mapscr),f))
629 {
630 goto error;
631 }
632 }
633 if (num_maps>1) //dungeon templates
634 {
635 for (int32_t i=0; i<TEMPLATES; i++)
636 {
637 if(!pfread(trashbuf,sizeof(mapscr),f))
638 {
639 goto error;
640 }
641 }
642 }
643
644 //yay! it worked! close the file and say everything was ok.
645 pack_fclose(f);
646 return true;
647
648 error:
649 pack_fclose(f);
650 return false;*/
651 }
652
653 bool valid_zqt(const char *filename)
654 {
655 PACKFILE *f=NULL;
656 bool isvalid;
657 int32_t error;
658 f=open_quest_file(&error, filename, false);
659
660 if(!f)
661 {
662 // setPackfilePassword(NULL);
663 return false;
664 }
665
666 isvalid=valid_zqt(f);
667
668 clear_quest_tmpfile();
669 pack_fclose(f);
670
671 // setPackfilePassword(NULL);
672 return isvalid;
673 }
674
675 /*
676 .qst file history
677
678 .qst files have always been compressed using allegro's packfiles.
679
680 At some point, an encoding layer was added. The two layers look like this:
681
682 1) The top layer is from us. See decode_file_007.
683 [0-24] Preamble "Zelda Classic Quest File"
684 [25-28] Initial decoding seed value.
685 [29-X] Allegro-compressed payload (AKA "packed" file), but XOR'd based on seed value
686 [last 4] Checksum
687
688 2) The bottom layer is a "compressed packed file" from Allegro 4. The entire payload
689 is XOR'd with a password (datapwd). Once that is undone, the first four bytes are "slh!",
690 followed by a lzss compressed representation of the payload (from allergo' packfile compression).
691 The oldest quests skip the password part.
692
693 Simply, the job of this function is to peel away the top layer.
694
695 With this second layer of encryption, the data isn't any more secure, and adds a significant delay
696 in opening and saving files. There is no version field, so they decryption key is
697 found via trial-by-error (very slow!)
698
699 There are other file types of interest:
700 - .zqt: quest template files, skips top-layer encryption pass
701 - .qsu: "unencoded" (and uncompressed) files; skips encryption and compression (also makes the longtan password moot)
702 - .qu?: same as above. automated backup files
703 - .qb?: same as above. automated backup files
704 - .qt?: compressed and encrypted (or not encrypted, as of May 2023)
705
706 May 2023: .qst files are now saved without the top layer encoding, and no allegro packfile password. The first bytes of these
707 files are now "slh!.AG ZC Enhanced Quest File".
708 The following command will take an existing qst file and upgrade it: `./zquest -unencrypt-qst <input> <output>`
709 */
710 128 PACKFILE *open_quest_file(int32_t *open_error, const char *filename, bool show_progress)
711 {
712
1/2
✓ Branch 0 taken 128 times.
✗ Branch 1 not taken.
128 if (show_progress)
713 {
714 box_start(1, "Loading Quest", get_zc_font(font_lfont), font, true);
715 }
716
717 128 auto unencrypted_result = try_open_maybe_legacy_encoded_file(filename, ENC_STR, nullptr, QH_NEWIDSTR, QH_IDSTR);
718
2/2
✓ Branch 0 taken 125 times.
✓ Branch 1 taken 3 times.
128 if (unencrypted_result.decoded_pf)
719 125 return unencrypted_result.decoded_pf;
720
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 if (unencrypted_result.not_found)
721 {
722 *open_error = qe_notfound;
723 return nullptr;
724 }
725
726 // Everything below here is legacy code - recently saved quest files will have
727 // returned by now.
728 // The only replay qst file that is still using this legacy encoding is `link_to_the_zelda.qst`.
729
730 // Note: although this is primarily for loading .qst files, it can also handle all of the
731 // file types mentioned in the comment above. No need to be told if the file being loaded
732 // is encrypted or compressed, we can do some simple and fast checks to determine how to load it.
733 3 bool top_layer_compressed = unencrypted_result.top_layer_compressed;
734 3 bool compressed = unencrypted_result.compressed;
735 3 bool encrypted = unencrypted_result.encrypted;
736
737 char tmpfilename[L_tmpnam];
738 3 temp_name(tmpfilename);
739 char percent_done[30];
740 3 int32_t current_method=0;
741
742 PACKFILE *f;
743 3 const char *passwd= encrypted ? datapwd : "";
744
745 // oldquest flag is set when an unencrypted qst file is suspected.
746 3 bool oldquest = false;
747 int32_t ret;
748
749
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(strcmp(filename, "default.qst")!=0)
750 {
751 3 box_out(filename);
752 3 }
753 else
754 {
755 box_out("new quest"); // Or whatever
756 }
757 3 box_out("...");
758 3 box_eol();
759 3 box_eol();
760
761
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(encrypted)
762 {
763 3 box_out("Decrypting...");
764 3 box_save_x();
765 3 ret = decode_file_007(filename, tmpfilename, ENC_STR, ENC_METHOD_MAX-1, top_layer_compressed, passwd);
766
767
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(ret)
768 {
769 switch(ret)
770 {
771 case 1:
772 box_out("error.");
773 box_eol();
774 box_end(true);
775 *open_error=qe_notfound;
776 return NULL;
777
778 case 2:
779 box_out("error.");
780 box_eol();
781 box_end(true);
782 *open_error=qe_internal;
783 return NULL;
784 // be sure not to delete tmpfilename now...
785 }
786
787 if(ret==5) //old encryption?
788 {
789 current_method++;
790 sprintf(percent_done, "%d%%", (current_method*100)/ENC_METHOD_MAX);
791 box_out(percent_done);
792 box_load_x();
793 ret = decode_file_007(filename, tmpfilename, ENC_STR, ENC_METHOD_211B9, strstr(filename, ".dat#")!=NULL, passwd);
794 }
795
796 if(ret==5) //old encryption?
797 {
798 current_method++;
799 sprintf(percent_done, "%d%%", (current_method*100)/ENC_METHOD_MAX);
800 box_out(percent_done);
801 box_load_x();
802 ret = decode_file_007(filename, tmpfilename, ENC_STR, ENC_METHOD_192B185, strstr(filename, ".dat#")!=NULL, passwd);
803 }
804
805 if(ret==5) //old encryption?
806 {
807 current_method++;
808 sprintf(percent_done, "%d%%", (current_method*100)/ENC_METHOD_MAX);
809 box_out(percent_done);
810 box_load_x();
811 ret = decode_file_007(filename, tmpfilename, ENC_STR, ENC_METHOD_192B105, strstr(filename, ".dat#")!=NULL, passwd);
812 }
813
814 if(ret==5) //old encryption?
815 {
816 current_method++;
817 sprintf(percent_done, "%d%%", (current_method*100)/ENC_METHOD_MAX);
818 box_out(percent_done);
819 box_load_x();
820 ret = decode_file_007(filename, tmpfilename, ENC_STR, ENC_METHOD_192B104, strstr(filename, ".dat#")!=NULL, passwd);
821 }
822
823 if(ret)
824 {
825 oldquest = true;
826 passwd="";
827 }
828 }
829
830 3 box_out("okay.");
831 3 box_eol();
832 3 }
833 else
834 {
835 oldquest = true;
836 }
837
838 3 box_out("Opening...");
839
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 f = pack_fopen_password(oldquest ? filename : tmpfilename, compressed ? F_READ_PACKED : F_READ, passwd);
840
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(!f)
841 {
842 if((compressed==1)&&(errno==EDOM))
843 {
844 f = pack_fopen_password(oldquest ? filename : tmpfilename, F_READ, passwd);
845 }
846
847 if(!f)
848 {
849 if(!oldquest)
850 {
851 delete_file(tmpfilename);
852 }
853 box_out("error.");
854 box_eol();
855 box_end(true);
856 *open_error=qe_invalid;
857 return NULL;
858 }
859 }
860
861
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 if(!oldquest)
862 {
863 3 delete_file(tmpfilename);
864 3 }
865
866 3 box_out("okay.");
867 3 box_eol();
868
869 3 return f;
870 128 }
871
872 PACKFILE *open_quest_template(zquestheader *Header, char *deletefilename, bool validate)
873 {
874 char *filename;
875 PACKFILE *f=NULL;
876 int32_t open_error=0;
877
878 strcpy(qstdat_string, "modules/classic/default.qst");
879 if(Header->templatepath[0]==0)
880 {
881 filename=(char *)malloc(2048);
882 strcpy(filename, qstdat_string);
883 }
884 else
885 {
886 // TODO: should be safe to remove this, no one seems to use custom quest templates.
887 filename=Header->templatepath;
888 }
889
890 f=open_quest_file(&open_error, filename, false);
891
892 if(Header->templatepath[0]==0)
893 {
894 free(filename);
895 }
896
897 if(!f)
898 {
899 return NULL;
900 }
901
902 if(validate)
903 {
904 if(!valid_zqt(f))
905 {
906 jwin_alert("Error","Invalid Quest Template",NULL,NULL,"O&K",NULL,'k',0,get_zc_font(font_lfont));
907 pack_fclose(f);
908 clear_quest_tmpfile();
909 return NULL;
910 }
911 }
912
913 return f;
914 }
915
916 bool init_section(zquestheader *Header, int32_t section_id, miscQdata *Misc, zctune *tunes, bool validate)
917 {
918 // We absolutely do not support loading from a template file to initialize data outside the editor.
919 // TODO: move this code into zq/
920 if (get_app_id() != App::zquest) return false;
921
922 combosread=false;
923 mapsread=false;
924 fixffcs=false;
925
926 switch(section_id)
927 {
928 case ID_RULES:
929 case ID_STRINGS:
930 case ID_MISC:
931 case ID_TILES:
932 case ID_COMBOS:
933 case ID_CSETS:
934 case ID_MAPS:
935 case ID_DMAPS:
936 case ID_DOORS:
937 case ID_ITEMS:
938 case ID_WEAPONS:
939 case ID_COLORS:
940 case ID_ICONS:
941 case ID_INITDATA:
942 case ID_GUYS:
943 case ID_MIDIS:
944 case ID_CHEATS:
945 case ID_ITEMDROPSETS:
946 case ID_FAVORITES:
947 break;
948
949 default:
950 return false;
951 break;
952 }
953
954 int32_t ret;
955 word version, build;
956 PACKFILE *f=NULL;
957
958 char deletefilename[1024];
959 deletefilename[0]=0;
960
961 //why is this here?
962 /*
963 if(colordata==NULL)
964 return false;
965 */
966
967 //setPackfilePassword(datapwd);
968 f=open_quest_template(Header, deletefilename, validate);
969
970 if(!f) //no file, nothing to delete
971 {
972 // setPackfilePassword(NULL);
973 return false;
974 }
975
976 ret=get_version_and_build(f, &version, &build);
977
978 if(ret||(version==0))
979 {
980 pack_fclose(f);
981 clear_quest_tmpfile();
982
983 if(deletefilename[0])
984 {
985 delete_file(deletefilename);
986 }
987
988 // setPackfilePassword(NULL);
989 return false;
990 }
991
992 if(!find_section(f, section_id))
993 {
994 al_trace("Can't find section!\n");
995 pack_fclose(f);
996 clear_quest_tmpfile();
997
998 if(deletefilename[0])
999 {
1000 delete_file(deletefilename);
1001 }
1002
1003 //setPackfilePassword(NULL);
1004 return false;
1005 }
1006
1007 switch(section_id)
1008 {
1009 case ID_RULES:
1010 //rules
1011 ret=readrules(f, Header);
1012 break;
1013
1014 case ID_STRINGS:
1015 //strings
1016 ret=readstrings(f, Header);
1017 break;
1018
1019 case ID_MISC:
1020 //misc data
1021 ret=readmisc(f, Header, Misc);
1022 break;
1023
1024 case ID_TILES:
1025 //tiles
1026 ret=readtiles(f, newtilebuf, Header, version, build, 0, NEWMAXTILES, true);
1027 break;
1028
1029 case ID_COMBOS:
1030 //combos
1031 clear_combos();
1032 ret=readcombos(f, Header, version, build, 0, MAXCOMBOS);
1033 combosread=true;
1034 break;
1035
1036 case ID_COMBOALIASES:
1037 //combos
1038 ret=readcomboaliases(f, Header, version, build);
1039 break;
1040
1041 case ID_CSETS:
1042 //color data
1043 ret=readcolordata(f, Misc, version, build, 0, newerpdTOTAL);
1044 break;
1045
1046 case ID_MAPS:
1047 //maps
1048 ret=readmaps(f, Header);
1049 mapsread=true;
1050 break;
1051
1052 case ID_DMAPS:
1053 //dmaps
1054 ret=readdmaps(f, Header, version, build, 0, MAXDMAPS);
1055 break;
1056
1057 case ID_DOORS:
1058 //door combo sets
1059 ret=readdoorcombosets(f, Header);
1060 break;
1061
1062 case ID_ITEMS:
1063 //items
1064 ret=readitems(f, version, build);
1065 break;
1066
1067 case ID_WEAPONS:
1068 //weapons
1069 ret=readweapons(f, Header);
1070 break;
1071
1072 case ID_COLORS:
1073 //misc. colors
1074 ret=readmisccolors(f, Header, Misc);
1075 break;
1076
1077 case ID_ICONS:
1078 //game icons
1079 ret=readgameicons(f, Header, Misc);
1080 break;
1081
1082 case ID_INITDATA:
1083 //initialization data
1084 ret=readinitdata(f, Header);
1085 break;
1086
1087 case ID_GUYS:
1088 //guys
1089 ret=readguys(f, Header);
1090 break;
1091
1092 case ID_MIDIS:
1093 //midis
1094 ret=readtunes(f, Header, tunes);
1095 break;
1096
1097 case ID_CHEATS:
1098 //cheat codes
1099 ret=readcheatcodes(f, Header);
1100 break;
1101
1102 case ID_ITEMDROPSETS:
1103 //item drop sets
1104 // Why is this one commented out?
1105 //ret=readitemdropsets(f, (int32_t)version, (word)build);
1106 break;
1107
1108 case ID_FAVORITES:
1109 // favorite combos and aliases
1110 ret=readfavorites(f, version, build);
1111 break;
1112
1113 default:
1114 ret=-1;
1115 break;
1116 }
1117
1118 pack_fclose(f);
1119 clear_quest_tmpfile();
1120
1121 if(deletefilename[0])
1122 {
1123 delete_file(deletefilename);
1124 }
1125
1126 //setPackfilePassword(NULL);
1127 if(!ret)
1128 {
1129 return true;
1130 }
1131
1132 return false;
1133 }
1134
1135 bool init_tiles(bool validate, zquestheader *Header)
1136 {
1137 return init_section(Header, ID_TILES, NULL, NULL, validate);
1138 }
1139
1140 bool init_combos(bool validate, zquestheader *Header)
1141 {
1142 return init_section(Header, ID_COMBOS, NULL, NULL, validate);
1143 }
1144
1145 bool init_colordata(bool validate, zquestheader *Header, miscQdata *Misc)
1146 {
1147 return init_section(Header, ID_CSETS, Misc, NULL, validate);
1148 }
1149
1150 128 void init_spritelists()
1151 {
1152
2/2
✓ Branch 0 taken 93 times.
✓ Branch 1 taken 35 times.
128 if(FFCore.quest_format[vZelda] < 0x255)
1153 {
1154 93 guys.setMax(255);
1155 93 items.setMax(255);
1156 93 Ewpns.setMax(255);
1157 93 Lwpns.setMax(255);
1158 93 chainlinks.setMax(255);
1159 93 decorations.setMax(255);
1160 93 particles.setMax(255);
1161 93 }
1162 else
1163 {
1164 35 guys.setMax(255);
1165 35 items.setMax(255);
1166 35 Ewpns.setMax(255);
1167 35 Lwpns.setMax(255);
1168 35 chainlinks.setMax(255);
1169 35 decorations.setMax(255);
1170 35 particles.setMax(255*((255*4)+1)); //255 per sprite that can use particles; guys, items, ewpns, lwpns, +HERO
1171 }
1172 128 }
1173
1174 114 bool reset_items(bool validate, zquestheader *Header)
1175 {
1176 114 bool ret = true;
1177
1/2
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
114 if (get_app_id() == App::zquest)
1178 ret = init_section(Header, ID_ITEMS, NULL, NULL, validate);
1179
1180
2/2
✓ Branch 0 taken 114 times.
✓ Branch 1 taken 29184 times.
29298 for(int32_t i=0; i<MAXITEMS; i++) reset_itemname(i);
1181
1182 114 return ret;
1183 }
1184
1185 bool reset_guys()
1186 {
1187 // The .dat file's guys definitions are always synchronised with defdata.cpp's - even the tile settings.
1188 init_guys(V_GUYS);
1189 return true;
1190 }
1191
1192 bool reset_wpns(bool validate, zquestheader *Header)
1193 {
1194 bool ret = true;
1195 if (get_app_id() == App::zquest)
1196 ret = init_section(Header, ID_WEAPONS, NULL, NULL, validate);
1197
1198 for(int32_t i=0; i<MAXWPNS; i++)
1199 reset_weaponname(i);
1200
1201 return ret;
1202 }
1203
1204 bool reset_mapstyles(bool validate, miscQdata *Misc)
1205 {
1206 Misc->colors.blueframe_tile = 20044;
1207 Misc->colors.blueframe_cset = 0;
1208 Misc->colors.triforce_tile = 23461;
1209 Misc->colors.triforce_cset = 1;
1210 Misc->colors.triframe_tile = 18752;
1211 Misc->colors.triframe_cset = 1;
1212 Misc->colors.overworld_map_tile = 16990;
1213 Misc->colors.overworld_map_cset = 2;
1214 Misc->colors.HCpieces_tile = 21160;
1215 Misc->colors.HCpieces_cset = 8;
1216 Misc->colors.dungeon_map_tile = 19651;
1217 Misc->colors.dungeon_map_cset = 8;
1218 return true;
1219 }
1220
1221 114 int32_t get_qst_buffers()
1222 {
1223 114 memrequested+=(sizeof(mapscr)*MAPSCRS);
1224 114 Z_message("Allocating map buffer (%s)... ", byte_conversion2(sizeof(mapscr)*MAPSCRS,memrequested,-1, -1));
1225 114 TheMaps.resize(MAPSCRS);
1226 114 map_autolayers.resize(6);
1227
1228
2/2
✓ Branch 0 taken 15504 times.
✓ Branch 1 taken 114 times.
15618 for(int32_t i(0); i<MAPSCRS; i++)
1229 15504 TheMaps[i].zero_memory();
1230
1231 //memset(TheMaps, 0, sizeof(mapscr)*MAPSCRS); //shouldn't need this anymore
1232 114 Z_message("OK\n");
1233
1234 // Allocating space for all 65535 strings uses up 10.62MB...
1235 // The vast majority of finished quests (and I presume this will be consistent for all time) use < 1000 strings in total.
1236 // (Shoelace's "Hero of Dreams" uses 1415.)
1237 // So let's be a bit generous and allow 4096 initially.
1238 // In the rare event that a quest overshoots this mark, we'll reallocate to the full 65535 later.
1239 // I tested it and it worked without flaw on 6/6/11. - L.
1240 // 2022: bumped from 4096 to 8192 to avoid a bug where the Strings menu shows (None) strings when the list passes
1241 // this threshold. Possibly some bug related to `msglistcache` to being reset?
1242 // See https://discord.com/channels/876899628556091432/992984989073416242
1243 114 msg_strings_size = 8192;
1244 114 memrequested+=(sizeof(MsgStr)*msg_strings_size);
1245 114 Z_message("Allocating string buffer (%s)... ", byte_conversion2(sizeof(MsgStr)*msg_strings_size,memrequested,-1,-1));
1246
1247
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 114 times.
114 MsgStrings = new MsgStr[msg_strings_size];
1248
1249 //memset(MsgStrings, 0, sizeof(MsgStr)*msg_strings_size);
1250
2/2
✓ Branch 0 taken 933888 times.
✓ Branch 1 taken 114 times.
934002 for(auto q = 0; q < msg_strings_size; ++q)
1251 {
1252 933888 MsgStrings[q].clear();
1253 933888 }
1254 114 Z_message("OK\n"); // Allocating string buffer...
1255
1256 114 memrequested+=(sizeof(DoorComboSet)*MAXDOORCOMBOSETS);
1257 114 Z_message("Allocating door combo buffer (%s)... ", byte_conversion2(sizeof(DoorComboSet)*MAXDOORCOMBOSETS,memrequested,-1,-1));
1258
1259
1/2
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
114 if((DoorComboSets=(DoorComboSet*)malloc(sizeof(DoorComboSet)*MAXDOORCOMBOSETS))==NULL)
1260 return 0;
1261
1262 114 Z_message("OK\n"); // Allocating door combo buffer...
1263
1264 114 memrequested+=(sizeof(dmap)*MAXDMAPS);
1265 114 Z_message("Allocating dmap buffer (%s)... ", byte_conversion2(sizeof(dmap)*MAXDMAPS,memrequested,-1,-1));
1266
1267
1/2
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
114 if((DMaps=new dmap[MAXDMAPS])==NULL)
1268 return 0;
1269
1270 114 Z_message("OK\n"); // Allocating dmap buffer...
1271
1272 114 memrequested+=(sizeof(newcombo)*MAXCOMBOS);
1273 114 Z_message("Allocating combo buffer (%s)... ", byte_conversion2(sizeof(newcombo)*MAXCOMBOS,memrequested,-1,-1));
1274
1275 114 combobuf.clear();
1276 114 combobuf.resize(MAXCOMBOS);
1277 114 Z_message("OK\n"); // Allocating combo buffer...
1278
1279 114 memrequested+=(psTOTAL255);
1280 114 Z_message("Allocating color data buffer (%s)... ", byte_conversion2(psTOTAL255,memrequested,-1,-1));
1281
1282
1/2
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
114 if((colordata=(byte*)malloc(psTOTAL255))==NULL)
1283 return 0;
1284
1285 114 Z_message("OK\n"); // Allocating color data buffer...
1286
1287 114 memrequested+=(NEWMAXTILES*(sizeof(tiledata)+tilesize(tf4Bit)));
1288 114 Z_message("Allocating tile buffer (%s)... ", byte_conversion2(NEWMAXTILES*(sizeof(tiledata)+tilesize(tf4Bit)),memrequested,-1,-1));
1289
1290 114 free_newtilebuf();
1291
1/2
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
114 if((newtilebuf=(tiledata*)malloc(NEWMAXTILES*sizeof(tiledata)))==NULL)
1292 return 0;
1293
1294 114 memset(newtilebuf, 0, NEWMAXTILES*sizeof(tiledata));
1295 //Z_message("Performed memset on tiles\n");
1296 114 clear_tiles(newtilebuf);
1297 //Z_message("Performed clear_tiles()\n");
1298 114 Z_message("OK\n"); // Allocating tile buffer...
1299
1300
1/2
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
114 if(is_editor())
1301 {
1302 memrequested+=(NEWMAXTILES*(sizeof(tiledata)+tilesize(tf4Bit)));
1303 Z_message("Allocating tile grab buffer (%s)... ", byte_conversion2(NEWMAXTILES*sizeof(tiledata),memrequested,-1,-1));
1304
1305 if((grabtilebuf=(tiledata*)malloc(NEWMAXTILES*sizeof(tiledata)))==NULL)
1306 return 0;
1307
1308 memset(grabtilebuf, 0, NEWMAXTILES*sizeof(tiledata));
1309 clear_tiles(grabtilebuf);
1310 Z_message("OK\n"); // Allocating tile grab buffer...
1311 }
1312
1313 114 memrequested+=(100000);
1314 114 Z_message("Allocating trash buffer (%s)... ", byte_conversion2(100000,memrequested,-1,-1));
1315
1316
1/2
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
114 if((trashbuf=(byte*)malloc(100000))==NULL)
1317 return 0;
1318
1319 114 Z_message("OK\n"); // Allocating trash buffer...
1320
1321 // Big, ugly band-aid here. Perhaps the most common cause of random crashes
1322 // has been inadvertently accessing itemsbuf[-1]. All such crashes should be
1323 // fixed by ensuring there's actually itemdata there.
1324 // If you change this, be sure to update del_qst_buffers, too.
1325
1326 114 memrequested+=(sizeof(itemdata)*(MAXITEMS+1));
1327 114 Z_message("Allocating item buffer (%s)... ", byte_conversion2(sizeof(itemdata)*(MAXITEMS+1),memrequested,-1,-1));
1328
1329
1/2
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
114 if((itemsbuf=(itemdata*)malloc(sizeof(itemdata)*(MAXITEMS+1)))==NULL)
1330 return 0;
1331
1332 114 memset(itemsbuf,0,sizeof(itemdata)*(MAXITEMS+1));
1333 114 itemsbuf++;
1334 114 Z_message("OK\n"); // Allocating item buffer...
1335
1336 114 memrequested+=(sizeof(wpndata)*MAXWPNS);
1337 114 Z_message("Allocating weapon buffer (%s)... ", byte_conversion2(sizeof(wpndata)*MAXWPNS,memrequested,-1,-1));
1338
1339
1/2
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
114 if((wpnsbuf=(wpndata*)malloc(sizeof(wpndata)*MAXWPNS))==NULL)
1340 return 0;
1341
1342 114 memset(wpnsbuf,0,sizeof(wpndata)*MAXWPNS);
1343 114 Z_message("OK\n"); // Allocating weapon buffer...
1344
1345 114 memrequested+=(sizeof(guydata)*MAXGUYS);
1346 114 Z_message("Allocating guy buffer (%s)... ", byte_conversion2(sizeof(guydata)*MAXGUYS,memrequested,-1,-1));
1347
1348
1/2
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
114 if((guysbuf=(guydata*)malloc(sizeof(guydata)*MAXGUYS))==NULL)
1349 return 0;
1350
1351 114 memset(guysbuf,0,sizeof(guydata)*MAXGUYS);
1352 114 Z_message("OK\n"); // Allocating guy buffer...
1353
1354 114 memrequested+=(sizeof(comboclass)*cMAX);
1355 114 Z_message("Allocating combo class buffer (%s)... ", byte_conversion2(sizeof(comboclass)*cMAX,memrequested,-1,-1));
1356
1357
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 114 times.
114 if((combo_class_buf=(comboclass*)malloc(sizeof(comboclass)*cMAX))==NULL)
1358 return 0;
1359
1360 114 Z_message("OK\n"); // Allocating combo class buffer...
1361
1362 114 return 1;
1363 114 }
1364
1365
1366 114 void free_newtilebuf()
1367 {
1368
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 114 times.
114 if(newtilebuf)
1369 {
1370 for(int32_t i=0; i<NEWMAXTILES; i++)
1371 if(newtilebuf[i].data)
1372 free(newtilebuf[i].data);
1373
1374 free(newtilebuf);
1375 newtilebuf = 0;
1376 }
1377 114 }
1378
1379 void free_grabtilebuf()
1380 {
1381 if(is_editor())
1382 {
1383 if(grabtilebuf)
1384 {
1385 for(int32_t i=0; i<NEWMAXTILES; i++)
1386 if(grabtilebuf[i].data) free(grabtilebuf[i].data);
1387
1388 free(grabtilebuf);
1389 grabtilebuf = 0;
1390 }
1391 }
1392 }
1393
1394 void del_qst_buffers()
1395 {
1396 if(MsgStrings) delete[] MsgStrings;
1397
1398 if(DoorComboSets) free(DoorComboSets);
1399
1400 if (DMaps) delete[] DMaps;
1401
1402 combobuf.clear();
1403
1404 if(colordata) free(colordata);
1405
1406 free_newtilebuf();
1407 free_grabtilebuf();
1408
1409 if(trashbuf) free(trashbuf);
1410
1411 // See get_qst_buffers
1412 if(itemsbuf)
1413 {
1414 itemsbuf--;
1415 free(itemsbuf);
1416 }
1417
1418 if(wpnsbuf) free(wpnsbuf);
1419
1420 if(guysbuf) free(guysbuf);
1421
1422 if(combo_class_buf) free(combo_class_buf);
1423 }
1424
1425 4 bool init_palnames()
1426 {
1427 // if(palnames==NULL)
1428 // return false;
1429
1430
2/2
✓ Branch 0 taken 2048 times.
✓ Branch 1 taken 4 times.
2052 for(int32_t x=0; x<MAXLEVELS; x++)
1431 {
1432
4/4
✓ Branch 0 taken 2036 times.
✓ Branch 1 taken 4 times.
✓ Branch 2 taken 4 times.
✓ Branch 3 taken 4 times.
2048 switch(x)
1433 {
1434 case 0:
1435 4 sprintf(palnames[x],"Overworld");
1436 4 break;
1437
1438 case 10:
1439 4 sprintf(palnames[x],"Caves");
1440 4 break;
1441
1442 case 11:
1443 4 sprintf(palnames[x],"Passageways");
1444 4 break;
1445
1446 default:
1447 2036 sprintf(palnames[x],"%c",0);
1448 2036 break;
1449 }
1450 2048 }
1451
1452 4 return true;
1453 }
1454
1455 25208 static void *read_block(PACKFILE *f, int32_t size, int32_t alloc_size)
1456 {
1457 void *p;
1458
1459
1/2
✓ Branch 0 taken 25208 times.
✗ Branch 1 not taken.
25208 p = _AL_MALLOC(MAX(size, alloc_size));
1460
1461
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 25208 times.
25208 if(!p)
1462 {
1463 return NULL;
1464 }
1465
1466
1/2
✓ Branch 0 taken 25208 times.
✗ Branch 1 not taken.
25208 if(!pfread(p,size,f))
1467 {
1468 _AL_FREE(p);
1469 return NULL;
1470 }
1471
1472
1/2
✓ Branch 0 taken 25208 times.
✗ Branch 1 not taken.
25208 if(pack_ferror(f))
1473 {
1474 _AL_FREE(p);
1475 return NULL;
1476 }
1477
1478 25208 return p;
1479 25208 }
1480
1481 // Only use for reading parts of older quests (Header->zelda_version <= 0x192)
1482 static const byte* legacy_skip_flags;
1483
1484 /* read_midi:
1485 * Reads MIDI data from a datafile (this is not the same thing as the
1486 * standard midi file format).
1487 */
1488
1489 2301 static MIDI *read_midi(PACKFILE *f)
1490 {
1491 MIDI *m;
1492 int32_t c;
1493 2301 int16_t divisions=0;
1494 2301 int32_t len=0;
1495
1496 2301 m = (MIDI*)_AL_MALLOC(sizeof(MIDI));
1497
1498
1/2
✓ Branch 0 taken 2301 times.
✗ Branch 1 not taken.
2301 if(!m)
1499 {
1500 return NULL;
1501 }
1502
1503
2/2
✓ Branch 0 taken 73632 times.
✓ Branch 1 taken 2301 times.
75933 for(c=0; c<MIDI_TRACKS; c++)
1504 {
1505 73632 m->track[c].len = 0;
1506 73632 m->track[c].data = NULL;
1507 73632 }
1508
1509 2301 p_mgetw(&divisions,f);
1510 2301 m->divisions=divisions;
1511
1512
2/2
✓ Branch 0 taken 73632 times.
✓ Branch 1 taken 2301 times.
75933 for(c=0; c<MIDI_TRACKS; c++)
1513 {
1514 73632 p_mgetl(&len,f);
1515 73632 m->track[c].len=len;
1516
1517
2/2
✓ Branch 0 taken 48424 times.
✓ Branch 1 taken 25208 times.
73632 if(m->track[c].len > 0)
1518 {
1519 25208 m->track[c].data = (byte*)read_block(f, m->track[c].len, 0);
1520
1521
1/2
✓ Branch 0 taken 25208 times.
✗ Branch 1 not taken.
25208 if(!m->track[c].data)
1522 {
1523 destroy_midi(m);
1524 return NULL;
1525 }
1526 25208 }
1527 73632 }
1528
1529 LOCK_DATA(m, sizeof(MIDI));
1530
1531
2/2
✓ Branch 0 taken 73632 times.
✓ Branch 1 taken 2301 times.
75933 for(c=0; c<MIDI_TRACKS; c++)
1532 {
1533
2/2
✓ Branch 0 taken 25208 times.
✓ Branch 1 taken 48424 times.
73632 if(m->track[c].data)
1534 {
1535 LOCK_DATA(m->track[c].data, m->track[c].len);
1536 25208 }
1537 73632 }
1538
1539 2301 return m;
1540 2301 }
1541
1542 void clear_combo(int32_t i)
1543 {
1544 combobuf[i].clear();
1545 }
1546
1547 void clear_combos()
1548 {
1549 for(int32_t tmpcounter=0; tmpcounter<MAXCOMBOS; tmpcounter++)
1550 clear_combo(tmpcounter);
1551 }
1552
1553 void pack_combos()
1554 {
1555 int32_t di = 0;
1556
1557 for(int32_t si=0; si<1024; si+=2)
1558 combobuf[di++] = combobuf[si];
1559
1560 for(; di<1024; di++)
1561 clear_combo(di);
1562 }
1563
1564 128 void reset_tunes(zctune *tune)
1565 {
1566
2/2
✓ Branch 0 taken 32256 times.
✓ Branch 1 taken 128 times.
32384 for(int32_t i=0; i<MAXCUSTOMTUNES; i++)
1567 {
1568 32256 tune[i].reset();
1569 32256 }
1570 128 }
1571
1572
1573 /*void reset_midi(zcmidi_ *m)
1574 {
1575 m->title[0]=0;
1576 m->loop=1;
1577 m->volume=144;
1578 m->start=0;
1579 m->loop_start=-1;
1580 m->loop_end=-1;
1581 if(m->midi)
1582 {
1583 destroy_midi(m->midi);
1584 }
1585 m->midi=NULL;
1586 }
1587
1588
1589 void reset_midis(zcmidi_ *m)
1590 {
1591 for(int32_t i=0; i<MAXCUSTOMMIDIS; i++)
1592 {
1593 reset_midi(m+i);
1594 }
1595 }
1596 */
1597
1598 void reset_scr(int32_t scr)
1599 {
1600 /*
1601 byte *di=((byte*)TheMaps)+(scr*sizeof(mapscr));
1602 for(unsigned i=0; i<sizeof(mapscr); i++)
1603 *(di++) = 0;
1604 TheMaps[scr].valid=mVERSION;
1605 */
1606
1607 TheMaps[scr].zero_memory();
1608 //byte *di=((byte*)TheMaps)+(scr*sizeof(mapscr));
1609
1610 for(int32_t i=0; i<6; i++)
1611 {
1612 //these will be uncommented later
1613 //TheMaps[scr].layerxsize[i]=16;
1614 //TheMaps[scr].layerysize[i]=11;
1615 TheMaps[scr].layeropacity[i]=255;
1616 }
1617
1618 TheMaps[scr].valid=mVERSION;
1619
1620 }
1621
1622 /* For reference:
1623
1624 enum { qe_OK, qe_notfound, qe_invalid, qe_version, qe_obsolete,
1625 qe_missing, qe_internal, qe_pwd, qe_match, qe_minver };
1626 */
1627
1628 3574 int32_t operator ==(DoorComboSet a, DoorComboSet b)
1629 {
1630
2/2
✓ Branch 0 taken 16422 times.
✓ Branch 1 taken 1606 times.
18028 for(int32_t i=0; i<9; i++)
1631 {
1632
2/2
✓ Branch 0 taken 88692 times.
✓ Branch 1 taken 14454 times.
103146 for(int32_t j=0; j<6; j++)
1633 {
1634
2/2
✓ Branch 0 taken 28908 times.
✓ Branch 1 taken 59784 times.
88692 if(j<4)
1635 {
1636
2/2
✓ Branch 0 taken 57816 times.
✓ Branch 1 taken 1968 times.
59784 if(a.doorcombo_u[i][j]!=b.doorcombo_u[i][j])
1637 {
1638 1968 return false;
1639 }
1640
1641
1/2
✓ Branch 0 taken 57816 times.
✗ Branch 1 not taken.
57816 if(a.doorcset_u[i][j]!=b.doorcset_u[i][j])
1642 {
1643 return false;
1644 }
1645
1646
1/2
✓ Branch 0 taken 57816 times.
✗ Branch 1 not taken.
57816 if(a.doorcombo_d[i][j]!=b.doorcombo_d[i][j])
1647 {
1648 return false;
1649 }
1650
1651
1/2
✓ Branch 0 taken 57816 times.
✗ Branch 1 not taken.
57816 if(a.doorcset_d[i][j]!=b.doorcset_d[i][j])
1652 {
1653 return false;
1654 }
1655 57816 }
1656
1657
1/2
✓ Branch 0 taken 86724 times.
✗ Branch 1 not taken.
86724 if(a.doorcombo_l[i][j]!=b.doorcombo_l[i][j])
1658 {
1659 return false;
1660 }
1661
1662
1/2
✓ Branch 0 taken 86724 times.
✗ Branch 1 not taken.
86724 if(a.doorcset_l[i][j]!=b.doorcset_l[i][j])
1663 {
1664 return false;
1665 }
1666
1667
1/2
✓ Branch 0 taken 86724 times.
✗ Branch 1 not taken.
86724 if(a.doorcombo_r[i][j]!=b.doorcombo_r[i][j])
1668 {
1669 return false;
1670 }
1671
1672
1/2
✓ Branch 0 taken 86724 times.
✗ Branch 1 not taken.
86724 if(a.doorcset_r[i][j]!=b.doorcset_r[i][j])
1673 {
1674 return false;
1675 }
1676 86724 }
1677
1678
2/2
✓ Branch 0 taken 11242 times.
✓ Branch 1 taken 3212 times.
14454 if(i<2)
1679 {
1680
1/2
✓ Branch 0 taken 3212 times.
✗ Branch 1 not taken.
3212 if(a.flags[i]!=b.flags[i])
1681 {
1682 return false;
1683 }
1684
1685
1/2
✓ Branch 0 taken 3212 times.
✗ Branch 1 not taken.
3212 if(a.bombdoorcombo_u[i]!=b.bombdoorcombo_u[i])
1686 {
1687 return false;
1688 }
1689
1690
1/2
✓ Branch 0 taken 3212 times.
✗ Branch 1 not taken.
3212 if(a.bombdoorcset_u[i]!=b.bombdoorcset_u[i])
1691 {
1692 return false;
1693 }
1694
1695
1/2
✓ Branch 0 taken 3212 times.
✗ Branch 1 not taken.
3212 if(a.bombdoorcombo_d[i]!=b.bombdoorcombo_d[i])
1696 {
1697 return false;
1698 }
1699
1700
1/2
✓ Branch 0 taken 3212 times.
✗ Branch 1 not taken.
3212 if(a.bombdoorcset_d[i]!=b.bombdoorcset_d[i])
1701 {
1702 return false;
1703 }
1704 3212 }
1705
1706
2/2
✓ Branch 0 taken 9636 times.
✓ Branch 1 taken 4818 times.
14454 if(i<3)
1707 {
1708
1/2
✓ Branch 0 taken 4818 times.
✗ Branch 1 not taken.
4818 if(a.bombdoorcombo_l[i]!=b.bombdoorcombo_l[i])
1709 {
1710 return false;
1711 }
1712
1713
1/2
✓ Branch 0 taken 4818 times.
✗ Branch 1 not taken.
4818 if(a.bombdoorcset_l[i]!=b.bombdoorcset_l[i])
1714 {
1715 return false;
1716 }
1717
1718
1/2
✓ Branch 0 taken 4818 times.
✗ Branch 1 not taken.
4818 if(a.bombdoorcombo_r[i]!=b.bombdoorcombo_r[i])
1719 {
1720 return false;
1721 }
1722
1723
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4818 times.
4818 if(a.bombdoorcset_r[i]!=b.bombdoorcset_r[i])
1724 {
1725 return false;
1726 }
1727 4818 }
1728
1729
1/2
✓ Branch 0 taken 14454 times.
✗ Branch 1 not taken.
14454 if(a.walkthroughcombo[i]!=b.walkthroughcombo[i])
1730 {
1731 return false;
1732 }
1733
1734
1/2
✓ Branch 0 taken 14454 times.
✗ Branch 1 not taken.
14454 if(a.walkthroughcset[i]!=b.walkthroughcset[i])
1735 {
1736 return false;
1737 }
1738 14454 }
1739
1740 1606 return true;
1741 3574 }
1742
1743 int32_t doortranslations_u[9][4]=
1744 {
1745 {37,38,53,54},
1746 {37,38,39,40},
1747 {37,38,55,56},
1748 {37,38,39,40},
1749 {37,38,53,54},
1750 {37,38,53,54},
1751 {37,38,53,54},
1752 {7,8,23,24},
1753 {7,8,41,42}
1754 };
1755
1756 int32_t doortranslations_d[9][4]=
1757 {
1758 {117,118,133,134},
1759 {135,136,133,134},
1760 {119,120,133,134},
1761 {135,136,133,134},
1762 {117,118,133,134},
1763 {117,118,133,134},
1764 {117,118,133,134},
1765 {151,152,167,168},
1766 {137,138,167,168},
1767 };
1768
1769 //enum {dt_pass=0, dt_lock, dt_shut, dt_boss, dt_olck, dt_osht, dt_obos, dt_wall, dt_bomb, dt_walk, dt_max};
1770 int32_t doortranslations_l[9][6]=
1771 {
1772 {66,67,82,83,98,99},
1773 {66,68,82,84,98,100},
1774 {66,69,82,85,98,101},
1775 {66,68,82,84,98,100},
1776 {66,67,82,83,98,99},
1777 {66,67,82,83,98,99},
1778 {66,67,82,83,98,99},
1779 {64,65,80,81,96,97},
1780 {64,65,80,114,96,97},
1781 };
1782
1783 int32_t doortranslations_r[9][6]=
1784 {
1785
1786 {76,77,92,93,108,109},
1787 {75,77,91,93,107,109},
1788 {74,77,90,93,106,109},
1789 {75,77,91,93,107,109},
1790 {76,77,92,93,108,109},
1791 {76,77,92,93,108,109},
1792 {76,77,92,93,108,109},
1793 {78,79,94,95,110,111},
1794 {78,79,125,95,110,111},
1795 };
1796
1797 314668 int32_t tdcmbdat(int32_t map, int32_t scr, int32_t pos)
1798 {
1799 314668 return (TheMaps[map*MAPSCRS+TEMPLATE].data[pos]&0xFF)+((TheMaps[map*MAPSCRS+scr].old_cpage)<<8);
1800 }
1801
1802 308180 int32_t tdcmbcset(int32_t map, int32_t scr, int32_t pos)
1803 {
1804 //these are here to bypass compiler warnings about unused arguments
1805 308180 map=map;
1806 308180 scr=scr;
1807 308180 pos=pos;
1808
1809 //what does this function do?
1810 // return TheMaps[map*MAPSCRS+TEMPLATE].cset[pos];
1811 308180 return 2;
1812 }
1813
1814 7072 int32_t MakeDoors(int32_t map, int32_t scr)
1815 {
1816
2/2
✓ Branch 0 taken 5450 times.
✓ Branch 1 taken 1622 times.
7072 if(!(TheMaps[map*MAPSCRS+scr].valid&mVALID))
1817 {
1818 5450 return 0;
1819 }
1820
1821 DoorComboSet tempdcs;
1822 1622 memset(&tempdcs, 0, sizeof(DoorComboSet));
1823
1824 //up
1825
2/2
✓ Branch 0 taken 14598 times.
✓ Branch 1 taken 1622 times.
16220 for(int32_t i=0; i<9; i++)
1826 {
1827
2/2
✓ Branch 0 taken 58392 times.
✓ Branch 1 taken 14598 times.
72990 for(int32_t j=0; j<4; j++)
1828 {
1829 58392 tempdcs.doorcombo_u[i][j]=tdcmbdat(map,scr,doortranslations_u[i][j]);
1830 58392 tempdcs.doorcset_u[i][j]=tdcmbcset(map,scr,doortranslations_u[i][j]);
1831 58392 }
1832 14598 }
1833
1834 1622 tempdcs.bombdoorcombo_u[0]=tdcmbdat(map,scr,57);
1835 1622 tempdcs.bombdoorcset_u[0]=tdcmbcset(map,scr,57);
1836 1622 tempdcs.bombdoorcombo_u[1]=tdcmbdat(map,scr,58);
1837 1622 tempdcs.bombdoorcset_u[1]=tdcmbcset(map,scr,58);
1838 1622 tempdcs.walkthroughcombo[0]=tdcmbdat(map,scr,34);
1839 1622 tempdcs.walkthroughcset[0]=tdcmbdat(map,scr,34);
1840
1841 //down
1842
2/2
✓ Branch 0 taken 14598 times.
✓ Branch 1 taken 1622 times.
16220 for(int32_t i=0; i<9; i++)
1843 {
1844
2/2
✓ Branch 0 taken 58392 times.
✓ Branch 1 taken 14598 times.
72990 for(int32_t j=0; j<4; j++)
1845 {
1846 58392 tempdcs.doorcombo_d[i][j]=tdcmbdat(map,scr,doortranslations_d[i][j]);
1847 58392 tempdcs.doorcset_d[i][j]=tdcmbcset(map,scr,doortranslations_d[i][j]);
1848 58392 }
1849 14598 }
1850
1851 1622 tempdcs.bombdoorcombo_d[0]=tdcmbdat(map,scr,121);
1852
1853 1622 tempdcs.bombdoorcset_d[0]=tdcmbcset(map,scr,121);
1854 1622 tempdcs.bombdoorcombo_d[1]=tdcmbdat(map,scr,122);
1855 1622 tempdcs.bombdoorcset_d[1]=tdcmbcset(map,scr,122);
1856 1622 tempdcs.walkthroughcombo[1]=tdcmbdat(map,scr,34);
1857 1622 tempdcs.walkthroughcset[1]=tdcmbdat(map,scr,34);
1858
1859 //left
1860 // TheMaps[i*MAPSCRS+j].warpdmap=TheOldMap.warpdmap;
1861
2/2
✓ Branch 0 taken 14598 times.
✓ Branch 1 taken 1622 times.
16220 for(int32_t i=0; i<9; i++)
1862 {
1863
2/2
✓ Branch 0 taken 87588 times.
✓ Branch 1 taken 14598 times.
102186 for(int32_t j=0; j<6; j++)
1864 {
1865 87588 tempdcs.doorcombo_l[i][j]=tdcmbdat(map,scr,doortranslations_l[i][j]);
1866 87588 tempdcs.doorcset_l[i][j]=tdcmbcset(map,scr,doortranslations_l[i][j]);
1867 87588 }
1868 14598 }
1869
1870
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1622 times.
1622 for(int32_t j=0; j>6; j++)
1871 {
1872 if((j!=2)&&(j!=3))
1873 {
1874 tempdcs.doorcombo_l[dt_bomb][j]=TheMaps[map*MAPSCRS+scr].data[doortranslations_l[dt_bomb][j]];
1875 tempdcs.doorcset_l[dt_bomb][j]=TheMaps[map*MAPSCRS+scr].cset[doortranslations_l[dt_bomb][j]];
1876 }
1877 }
1878
1879 1622 tempdcs.bombdoorcombo_l[0]=0;
1880 1622 tempdcs.bombdoorcset_l[0]=tdcmbcset(map,scr,115);
1881 1622 tempdcs.bombdoorcombo_l[1]=tdcmbdat(map,scr,115);
1882 1622 tempdcs.bombdoorcset_l[1]=tdcmbcset(map,scr,115);
1883 1622 tempdcs.bombdoorcombo_l[2]=0;
1884 1622 tempdcs.bombdoorcset_l[2]=tdcmbcset(map,scr,115);
1885 1622 tempdcs.walkthroughcombo[2]=tdcmbdat(map,scr,34);
1886 1622 tempdcs.walkthroughcset[2]=tdcmbdat(map,scr,34);
1887
1888 //right
1889
2/2
✓ Branch 0 taken 14598 times.
✓ Branch 1 taken 1622 times.
16220 for(int32_t i=0; i<9; i++)
1890 {
1891
2/2
✓ Branch 0 taken 87588 times.
✓ Branch 1 taken 14598 times.
102186 for(int32_t j=0; j<6; j++)
1892 {
1893 87588 tempdcs.doorcombo_r[i][j]=tdcmbdat(map,scr,doortranslations_r[i][j]);
1894 87588 tempdcs.doorcset_r[i][j]=tdcmbcset(map,scr,doortranslations_r[i][j]);
1895 87588 }
1896 14598 }
1897
1898
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1622 times.
1622 for(int32_t j=0; j>6; j++)
1899 {
1900 if((j!=2)&&(j!=3))
1901 {
1902 tempdcs.doorcombo_r[dt_bomb][j]=TheMaps[map*MAPSCRS+scr].data[doortranslations_r[dt_bomb][j]];
1903 tempdcs.doorcset_r[dt_bomb][j]=TheMaps[map*MAPSCRS+scr].cset[doortranslations_r[dt_bomb][j]];
1904 }
1905 }
1906
1907 1622 tempdcs.bombdoorcombo_r[0]=0;
1908 1622 tempdcs.bombdoorcset_r[0]=tdcmbcset(map,scr,124);
1909 1622 tempdcs.bombdoorcombo_r[1]=tdcmbdat(map,scr,124);
1910 1622 tempdcs.bombdoorcset_r[1]=tdcmbcset(map,scr,124);
1911 1622 tempdcs.bombdoorcombo_r[2]=0;
1912 1622 tempdcs.bombdoorcset_r[2]=tdcmbcset(map,scr,124);
1913 1622 tempdcs.walkthroughcombo[3]=tdcmbdat(map,scr,34);
1914 1622 tempdcs.walkthroughcset[3]=tdcmbdat(map,scr,34);
1915
1916 int32_t k;
1917
1918
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 3574 times.
3590 for(k=0; k<door_combo_set_count; k++)
1919 {
1920
2/2
✓ Branch 0 taken 1606 times.
✓ Branch 1 taken 1968 times.
3574 if(DoorComboSets[k]==tempdcs)
1921 {
1922 1606 break;
1923 }
1924 1968 }
1925
1926
2/2
✓ Branch 0 taken 1606 times.
✓ Branch 1 taken 16 times.
1622 if(k==door_combo_set_count)
1927 {
1928 16 DoorComboSets[k]=tempdcs;
1929 16 sprintf(DoorComboSets[k].name, "Door Combo Set %d", k);
1930 16 ++door_combo_set_count;
1931 16 }
1932
1933 1622 return k;
1934 /*
1935 doorcombo_u[9][4];
1936 doorcset_u[9][4];
1937 doorcombo_d[9][4];
1938 doorcset_d[9][4];
1939 doorcombo_l[9][6];
1940 doorcset_l[9][6];
1941 doorcombo_r[9][6];
1942 doorcset_r[9][6];
1943 bombdoorcombo_u[2];
1944 bombdoorcset_u[2];
1945 bombdoorcombo_d[2];
1946 bombdoorcset_d[2];
1947 bombdoorcombo_l[3];
1948 bombdoorcset_l[3];
1949 bombdoorcombo_r[3];
1950 bombdoorcset_r[3];
1951 walkthroughcombo[4];
1952 walkthroughcset[4];
1953 */
1954 7072 }
1955
1956 905216 INLINE int32_t tcmbdat2(int32_t map, int32_t scr, int32_t pos)
1957 {
1958 905216 return (TheMaps[map*MAPSCRS+TEMPLATE2].data[pos]&0xFF)+((TheMaps[map*MAPSCRS+scr].old_cpage)<<8);
1959 }
1960
1961 905216 INLINE int32_t tcmbcset2(int32_t map, int32_t pos)
1962 {
1963
1964 905216 return TheMaps[map*MAPSCRS+TEMPLATE2].cset[pos];
1965 }
1966
1967 905216 INLINE int32_t tcmbflag2(int32_t map, int32_t pos)
1968 {
1969 905216 return TheMaps[map*MAPSCRS+TEMPLATE2].sflag[pos];
1970 }
1971
1972
1973 16 void get_questpwd(char *encrypted_pwd, int16_t pwdkey, char *pwd)
1974 {
1975 char temp_pwd[30];
1976 16 memset(temp_pwd,0,30);
1977
1978
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(pwdkey!=0)
1979 {
1980 16 memcpy(temp_pwd,encrypted_pwd,30);
1981 16 temp_pwd[29]=0;
1982
1983
2/2
✓ Branch 0 taken 480 times.
✓ Branch 1 taken 16 times.
496 for(int32_t i=0; i<30; i++)
1984 {
1985 480 temp_pwd[i] -= pwdkey;
1986 480 int32_t t=pwdkey>>15;
1987 480 pwdkey = (pwdkey<<1)+t;
1988 480 }
1989 16 }
1990
1991 16 memcpy(pwd,temp_pwd,30);
1992 16 }
1993
1994
1995 92 bool devpwd()
1996 {
1997 #ifdef _DEBUG
1998 return true;
1999 #endif
2000
1/2
✓ Branch 0 taken 92 times.
✗ Branch 1 not taken.
92 return !strcmp(zc_get_config("dev","pwd","",App::zquest), (char*)clavio) || is_ci();
2001 }
2002 bool check_questpwd(zquestheader *Header, char *pwd)
2003 {
2004 #if DEVLEVEL > 3
2005 return true;
2006 #endif
2007
2008 if (devpwd()) return true;
2009 if ( (!strcmp(pwd, (char*)clavio)) ) return true;
2010 cvs_MD5Context ctx;
2011 uint8_t md5sum[16];
2012
2013 cvs_MD5Init(&ctx);
2014 cvs_MD5Update(&ctx, (const uint8_t*)pwd, (unsigned)strlen(pwd));
2015 cvs_MD5Final(md5sum, &ctx);
2016
2017 return (memcmp(Header->pwd_hash,md5sum,16)==0);
2018 }
2019
2020 120 void print_quest_metadata(zquestheader const& tempheader, char const* path, byte qst_num)
2021 {
2022 120 zprint2("\n");
2023 120 zprint2("[ZQUEST CREATOR METADATA]\n");
2024
1/2
✓ Branch 0 taken 120 times.
✗ Branch 1 not taken.
120 if(qst_num < moduledata.max_quest_files)
2025 zprint2("Loading module quest %d\n", qst_num+1);
2026
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 120 times.
120 if(path) zprint2("Loading '%s'\n", path);
2027
2/2
✓ Branch 0 taken 116 times.
✓ Branch 1 taken 4 times.
120 if ( tempheader.new_version_id_main > 0 )
2028 {
2029
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 116 times.
116 if(tempheader.new_version_id_fourth > 0)
2030 zprint2("Last saved in ZQuest Version %d.%d.%d.%d ",
2031 tempheader.new_version_id_main,tempheader.new_version_id_second,
2032 tempheader.new_version_id_third,tempheader.new_version_id_fourth);
2033 116 else zprint2("Last saved in ZQuest Version: %d.%d.%d ",
2034 116 tempheader.new_version_id_main,tempheader.new_version_id_second,
2035 116 tempheader.new_version_id_third);
2036 116 }
2037 else
2038 {
2039
1/6
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 4 times.
✗ Branch 5 not taken.
4 switch ( tempheader.zelda_version )
2040 {
2041 case 0x255:
2042 {
2043 zprint2("Last saved in ZQuest Version: 2.55.0, %s: %d", tempheader.getAlphaStr(), tempheader.getAlphaVer());
2044 break;
2045 }
2046 case 0x254:
2047 {
2048 zprint2("Last saved in ZQuest Version: 2.54.0, Alpha Build ID: %d", tempheader.build);
2049 break;
2050 }
2051 case 0x250:
2052 {
2053 switch(tempheader.build)
2054 {
2055 case 19:
2056 zprint2("Last saved in ZQuest Version: 2.50.0, Gamma 1"); break;
2057 case 20:
2058 zprint2("Last saved in ZQuest Version: 2.50.0, Gamma 2"); break;
2059 case 21:
2060 zprint2("Last saved in ZQuest Version: 2.50.0, Gamma 3"); break;
2061 case 22:
2062 zprint2("Last saved in ZQuest Version: 2.50.0, Gamma 4"); break;
2063 case 23:
2064 zprint2("Last saved in ZQuest Version: 2.50.0, Gamma 5"); break;
2065 case 24:
2066 zprint2("Last saved in ZQuest Version: 2.50.0, Release"); break;
2067 case 25:
2068 zprint2("Last saved in ZQuest Version: 2.50.1, Gamma 1"); break;
2069 case 26:
2070 zprint2("Last saved in ZQuest Version: 2.50.1, Gamma 2"); break;
2071 case 27:
2072 zprint2("Last saved in ZQuest Version: 2.50.1, Gamma 3"); break;
2073 case 28:
2074 zprint2("Last saved in ZQuest Version: 2.50.1, Release"); break;
2075 case 29:
2076 zprint2("Last saved in ZQuest Version: 2.50.2, Release"); break;
2077 case 30:
2078 zprint2("Last saved in ZQuest Version: 2.50.3, Gamma 1"); break;
2079 case 31:
2080 zprint2("Last saved in ZQuest Version: 2.53.0, Prior to Gamma 3"); break;
2081 case 32:
2082 zprint2("Last saved in ZQuest Version: 2.53.0"); break;
2083 case 33:
2084 zprint2("Last saved in ZQuest Version: 2.53.1"); break;
2085 default:
2086 zprint2("Last saved in ZQuest Version: %x, Build %d", tempheader.zelda_version,tempheader.build); break;
2087
2088 }
2089 break;
2090 }
2091
2092 case 0x211:
2093 {
2094 zprint2("Last saved in ZQuest Version: 2.11, Beta %d", tempheader.build); break;
2095 }
2096 case 0x210:
2097 {
2098 zprint2("Last saved in ZQuest Version: 2.10.x");
2099 if ( tempheader.build ) zprint2("Beta/Build %d\n", tempheader.build);
2100 break;
2101 }
2102 /* These versions cannot be handled here; they will be incorrect at this time. -Z
2103 case 0x193:
2104 {
2105 zprint2("Last saved in ZQuest Version: 1.93, Beta %d\n", tempheader.build); break;
2106 }
2107 case 0x192:
2108 {
2109 zprint2("Last saved in ZQuest Version: 1.92, Beta %d\n", tempheader.build); break;
2110 }
2111 case 0x190:
2112 {
2113 zprint2("Last saved in ZQuest Version: 1.90, Beta/Build %d\n", tempheader.build); break;
2114 }
2115 case 0x184:
2116 {
2117 zprint2("Last saved in ZQuest Version: 1.84, Beta/Build %d\n", tempheader.build); break;
2118 }
2119 case 0x183:
2120 {
2121 zprint2("Last saved in ZQuest Version: 1.83, Beta/Build %d\n", tempheader.build); break;
2122 }
2123 case 0x180:
2124 {
2125 zprint2("Last saved in ZQuest Version: 1.80, Beta/Build %d\n", tempheader.build); break;
2126 }
2127 default:
2128 {
2129 zprint2("Last saved in ZQuest Version: %x, Beta %d\n", tempheader.zelda_version,tempheader.build); break;
2130 }
2131 */
2132 }
2133 }
2134
3/4
✓ Branch 0 taken 27 times.
✓ Branch 1 taken 93 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 27 times.
120 if(!tempheader.is_legacy() && tempheader.getAlphaVer())
2135 27 zprint2("%s\n", tempheader.getAlphaVerStr());
2136 93 else zprint2("\n");
2137
2/2
✓ Branch 0 taken 93 times.
✓ Branch 1 taken 27 times.
120 if ( tempheader.made_in_module_name[0] ) zprint2("Created with ZC Module: %s\n\n", tempheader.made_in_module_name);
2138
2/2
✓ Branch 0 taken 93 times.
✓ Branch 1 taken 27 times.
120 if ( tempheader.new_version_devsig[0] ) zprint2("Developr Signoff by: %s\n", tempheader.new_version_devsig);
2139
2/2
✓ Branch 0 taken 93 times.
✓ Branch 1 taken 27 times.
120 if ( tempheader.new_version_compilername[0] ) zprint2("Compiled with: %s, (ID: %d)\n", tempheader.new_version_compilername, tempheader.compilerid);
2140
2/2
✓ Branch 0 taken 93 times.
✓ Branch 1 taken 27 times.
120 if ( tempheader.new_version_compilerversion[0] ) zprint2("Compiler Version: %s, (%d,%d,%d,%d)\n", tempheader.new_version_compilerversion,tempheader.compilerversionnumber_first,tempheader.compilerversionnumber_second,tempheader.compilerversionnumber_third,tempheader.compilerversionnumber_fourth);
2141
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 116 times.
120 if ( tempheader.product_name[0] ) zprint2("Project ID: %s\n", tempheader.product_name);
2142
2/2
✓ Branch 0 taken 93 times.
✓ Branch 1 taken 27 times.
120 if ( tempheader.new_version_id_date_day ) zprint2("Editor Built at date and time: %d-%d-%d at @ %s %s\n", tempheader.new_version_id_date_day, tempheader.new_version_id_date_month, tempheader.new_version_id_date_year, tempheader.build_timestamp, tempheader.build_timezone);
2143 120 zprint2("\n");
2144 120 }
2145
2146 128 int32_t readheader(PACKFILE *f, zquestheader *Header, byte printmetadata)
2147 {
2148 int32_t dummy;
2149 zquestheader tempheader;
2150 char dummybuf[80];
2151 byte temp_map_count;
2152 byte temp_midi_flags[MIDIFLAGS_SIZE];
2153 word version;
2154 char temp_pwd[30], temp_pwd2[30];
2155 int16_t temp_pwdkey;
2156 cvs_MD5Context ctx;
2157 128 memset(temp_midi_flags, 0, MIDIFLAGS_SIZE);
2158 128 memset(&tempheader, 0, sizeof(tempheader));
2159 128 memset(FFCore.quest_format, 0, sizeof(FFCore.quest_format));
2160
2161
2162
2163
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 128 times.
128 if(!pfread(tempheader.id_str,sizeof(tempheader.id_str),f)) // first read old header
2164 {
2165 Z_message("Unable to read header string\n");
2166 return qe_invalid;
2167 }
2168
2169 // check header
2170
2/2
✓ Branch 0 taken 124 times.
✓ Branch 1 taken 4 times.
128 if(strcmp(tempheader.id_str,QH_NEWIDSTR))
2171 {
2172
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(strcmp(tempheader.id_str,QH_IDSTR))
2173 {
2174 Z_message("Invalid header string: '%s' (was expecting '%s' or '%s')\n", tempheader.id_str, QH_IDSTR, QH_NEWIDSTR);
2175 return qe_invalid;
2176 }
2177 4 }
2178
2179 128 int32_t templatepath_len=0;
2180
2181 128 tempheader.external_zinfo = false;
2182 128 read_zinfo = false;
2183
2/2
✓ Branch 0 taken 124 times.
✓ Branch 1 taken 4 times.
128 if(!strcmp(tempheader.id_str,QH_IDSTR)) //pre-1.93 version
2184 {
2185 byte padding;
2186
2187
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_getc(&padding,f))
2188 {
2189 return qe_invalid;
2190 }
2191
2192
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_igetw(&tempheader.zelda_version,f))
2193 {
2194 return qe_invalid;
2195 }
2196
2197 4 FFCore.quest_format[vZelda] = tempheader.zelda_version;
2198
2199
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(tempheader.zelda_version > ZELDA_VERSION)
2200 {
2201 return qe_version;
2202 }
2203
2204 4 FFCore.quest_format[vZelda] = tempheader.zelda_version;
2205
2206
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(strcmp(tempheader.id_str,QH_IDSTR))
2207 {
2208 return qe_invalid;
2209 }
2210
2211
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(bad_version(tempheader.zelda_version))
2212 {
2213 return qe_obsolete;
2214 }
2215
2216
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_igetw(&tempheader.internal,f))
2217 {
2218 return qe_invalid;
2219 }
2220
2221
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_getc(&tempheader.quest_number,f))
2222 {
2223 return qe_invalid;
2224 }
2225
2226 4 FFCore.quest_format[qQuestNumber] = tempheader.quest_number;
2227
2228
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!pfread(&quest_rules[0],2,f))
2229 {
2230 return qe_invalid;
2231 }
2232
2233
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_getc(&temp_map_count,f))
2234 {
2235 return qe_invalid;
2236 }
2237
2238 4 FFCore.quest_format[qMapCount] = temp_map_count;
2239
2240
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_getc(&tempheader.old_str_count,f))
2241 {
2242 return qe_invalid;
2243 }
2244
2245
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_getc(&tempheader.data_flags[ZQ_TILES],f))
2246 {
2247 return qe_invalid;
2248 }
2249
2250
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!pfread(temp_midi_flags,4,f))
2251 {
2252 return qe_invalid;
2253 }
2254
2255
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_getc(&tempheader.data_flags[ZQ_CHEATS2],f))
2256 {
2257 return qe_invalid;
2258 }
2259
2260
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!pfread(dummybuf,14,f))
2261 {
2262 return qe_invalid;
2263 }
2264
2265
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!pfread(&quest_rules[2],2,f))
2266 {
2267 return qe_invalid;
2268 }
2269
2270
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_getc(&dummybuf,f))
2271 {
2272 return qe_invalid;
2273 }
2274
2275
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!pfread(tempheader.version,9,f))
2276 {
2277 return qe_invalid;
2278 }
2279
2280
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!pfread(tempheader.title,sizeof(tempheader.title),f))
2281 {
2282 return qe_invalid;
2283 }
2284 // These fields are expected to end in null bytes!
2285 4 tempheader.title[sizeof(tempheader.title)-1] = 0;
2286
2287
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!pfread(tempheader.author,sizeof(tempheader.author),f))
2288 {
2289 return qe_invalid;
2290 }
2291 4 tempheader.author[sizeof(tempheader.author)-1] = 0;
2292
2293
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_getc(&padding,f))
2294 {
2295 return qe_invalid;
2296 }
2297
2298
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_igetw(&temp_pwdkey,f))
2299 {
2300 return qe_invalid;
2301 }
2302
2303
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!pfread(temp_pwd,30,f))
2304 {
2305 return qe_invalid;
2306 }
2307
2308 4 get_questpwd(temp_pwd, temp_pwdkey, temp_pwd2);
2309 4 cvs_MD5Init(&ctx);
2310 4 cvs_MD5Update(&ctx, (const uint8_t*)temp_pwd2, (unsigned)strnlen(temp_pwd2, 30));
2311 4 cvs_MD5Final(tempheader.pwd_hash, &ctx);
2312
2313
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(tempheader.zelda_version < 0x177) // lacks new header stuff...
2314 {
2315 //memset(tempheader.minver,0,20); // char minver[9], byte build, byte foo[10]
2316 // Not anymore...
2317 memset(tempheader.minver,0,17);
2318 tempheader.build=0;
2319 tempheader.use_keyfile=0;
2320 memset(tempheader.old_foo, 0, 9);
2321 }
2322 else
2323 {
2324
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!pfread(tempheader.minver,9,f))
2325 {
2326 return qe_invalid;
2327 }
2328
2329
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_getc(&tempheader.build,f))
2330 {
2331 return qe_invalid;
2332 }
2333
2334 4 FFCore.quest_format[vBuild] = tempheader.build;
2335
2336
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_getc(&tempheader.use_keyfile,f))
2337 {
2338 return qe_invalid;
2339 }
2340
2341
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!pfread(dummybuf,9,f))
2342 {
2343 return qe_invalid;
2344 }
2345 } // starting at minver
2346
2347
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(tempheader.zelda_version < 0x187) // lacks newer header stuff...
2348 {
2349 memset(&quest_rules[4],0,16); // word rules3..rules10
2350 }
2351 else
2352 {
2353
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!pfread(&quest_rules[4],16,f)) // read new header additions
2354 {
2355 return qe_invalid; // starting at rules3
2356 }
2357
2358
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(tempheader.zelda_version <= 0x190)
2359 {
2360 4 set_qr(qr_MEANPLACEDTRAPS,0);
2361 4 }
2362 }
2363
2364
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
4 if((tempheader.zelda_version < 0x192)||
2365 ((tempheader.zelda_version == 0x192)&&(tempheader.build<149)))
2366 {
2367 4 set_qr(qr_BRKNSHLDTILES,(get_qr(qr_BRKBLSHLDS_DEP)));
2368 4 set_bit(deprecated_rules,qr_BRKBLSHLDS_DEP,1);
2369 4 set_qr(qr_BRKBLSHLDS_DEP,1);
2370 4 }
2371
2372
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(tempheader.zelda_version >= 0x192) // lacks newer header stuff...
2373 {
2374 byte *mf=temp_midi_flags;
2375
2376 if((tempheader.zelda_version == 0x192)&&(tempheader.build<178))
2377 {
2378 mf=(byte*)dummybuf;
2379 }
2380
2381 if(!pfread(mf,32,f)) // read new header additions
2382 {
2383 return qe_invalid; // starting at foo2
2384 }
2385
2386 if(!pfread(dummybuf,18,f)) // read new header additions
2387 {
2388 return qe_invalid; // starting at foo2
2389 }
2390 }
2391
2392
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
4 if((tempheader.zelda_version < 0x192)||
2393 ((tempheader.zelda_version == 0x192)&&(tempheader.build<145)))
2394 {
2395 4 memset(tempheader.templatepath,0,2048);
2396 4 }
2397 else
2398 {
2399 if(!pfread(tempheader.templatepath,280,f)) // read templatepath
2400 {
2401 return qe_invalid;
2402 }
2403 }
2404
2405
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
4 if((tempheader.zelda_version < 0x192)||
2406 ((tempheader.zelda_version == 0x192)&&(tempheader.build<186)))
2407 {
2408 4 tempheader.use_keyfile=0;
2409 4 }
2410 4 }
2411 else
2412 {
2413 //section id
2414
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 124 times.
124 if(!p_mgetl(&dummy,f))
2415 {
2416 return qe_invalid;
2417 }
2418
2419 //section version info
2420
1/2
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
124 if(!p_igetw(&version,f))
2421 {
2422 return qe_invalid;
2423 }
2424
2425 124 FFCore.quest_format[vHeader] = version;
2426
2427
1/2
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
124 if(!p_igetw(&dummy,f))
2428 {
2429 return qe_invalid;
2430 }
2431
2432 //section size
2433
1/2
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
124 if(!p_igetl(&dummy,f))
2434 {
2435 return qe_invalid;
2436 }
2437
2438 //finally... section data
2439
1/2
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
124 if(!p_igetw(&tempheader.zelda_version,f))
2440 {
2441 return qe_invalid;
2442 }
2443
2444 124 FFCore.quest_format[vZelda] = tempheader.zelda_version;
2445
2446 //do some quick checking...
2447
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 124 times.
124 if(tempheader.zelda_version > ZELDA_VERSION)
2448 {
2449 return qe_version;
2450 }
2451
2452
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 124 times.
124 if(strcmp(tempheader.id_str,QH_NEWIDSTR))
2453 {
2454 return qe_invalid;
2455 }
2456
2457
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 124 times.
124 if(bad_version(tempheader.zelda_version))
2458 {
2459 return qe_obsolete;
2460 }
2461
2462
1/2
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
124 if(!p_getc(&tempheader.build,f))
2463 {
2464 return qe_invalid;
2465 }
2466
2467 124 FFCore.quest_format[vBuild] = tempheader.build;
2468
2469
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 112 times.
124 if(version<3)
2470 {
2471
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!pfread(temp_pwd,30,f))
2472 {
2473 return qe_invalid;
2474 }
2475
2476
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!p_igetw(&temp_pwdkey,f))
2477 {
2478 return qe_invalid;
2479 }
2480
2481 12 get_questpwd(temp_pwd, temp_pwdkey, temp_pwd2);
2482 12 cvs_MD5Init(&ctx);
2483 12 cvs_MD5Update(&ctx, (const uint8_t*)temp_pwd2, (unsigned)strnlen(temp_pwd2, 30));
2484 12 cvs_MD5Final(tempheader.pwd_hash, &ctx);
2485 12 }
2486 else
2487 {
2488
1/2
✓ Branch 0 taken 112 times.
✗ Branch 1 not taken.
112 if(!pfread(tempheader.pwd_hash,sizeof(tempheader.pwd_hash),f))
2489 {
2490 return qe_invalid;
2491 }
2492 }
2493
2494
1/2
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
124 if(!p_igetw(&tempheader.internal,f))
2495 {
2496 return qe_invalid;
2497 }
2498
2499
1/2
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
124 if(!p_getc(&tempheader.quest_number,f))
2500 {
2501 return qe_invalid;
2502 }
2503
2504 124 FFCore.quest_format[qQuestNumber] = tempheader.quest_number;
2505
2506 124 size_t versz = version < 8 ? 9 : 16;
2507
1/2
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
124 if(!pfread(tempheader.version,versz,f))
2508 {
2509 return qe_invalid;
2510 }
2511
2512 //FFCore.quest_format[qQuestVersion] = tempheader.version;
2513 //needs to be copied as char[9] or stored as a s.str
2514
1/2
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
124 if(!pfread(tempheader.minver,versz,f))
2515 {
2516 return qe_invalid;
2517 }
2518
2519 //FFCore.quest_format[qMinQuestVersion] = tempheader.minver;
2520
1/2
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
124 if(!pfread(tempheader.title,sizeof(tempheader.title),f))
2521 {
2522 return qe_invalid;
2523 }
2524 124 tempheader.title[sizeof(tempheader.title)-1] = 0;
2525
2526
1/2
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
124 if(!pfread(tempheader.author,sizeof(tempheader.author),f))
2527 {
2528 return qe_invalid;
2529 }
2530 124 tempheader.author[sizeof(tempheader.author)-1] = 0;
2531
2532
1/2
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
124 if(!p_getc(&tempheader.use_keyfile,f))
2533 {
2534 return qe_invalid;
2535 }
2536
2537 /*
2538 if(!pfread(tempheader.data_flags,sizeof(tempheader.data_flags),f))
2539 {
2540 return qe_invalid;
2541 }
2542 */
2543
1/2
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
124 if(!p_getc(&tempheader.data_flags[ZQ_TILES],f))
2544 {
2545 return qe_invalid;
2546 }
2547
2548
1/2
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
124 if(!pfread(&dummybuf,4,f))
2549 {
2550 return qe_invalid;
2551 }
2552
2553
1/2
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
124 if(!p_getc(&tempheader.data_flags[ZQ_CHEATS2],f))
2554 {
2555 return qe_invalid;
2556 }
2557
2558
1/2
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
124 if(!pfread(dummybuf,14,f))
2559 {
2560 return qe_invalid;
2561 }
2562
2563 124 templatepath_len=sizeof(tempheader.templatepath);
2564
2565
2/2
✓ Branch 0 taken 112 times.
✓ Branch 1 taken 12 times.
124 if(version==1)
2566 {
2567 12 templatepath_len=280;
2568 12 }
2569
2570
1/2
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
124 if(!pfread(tempheader.templatepath,templatepath_len,f))
2571 {
2572 return qe_invalid;
2573 }
2574
2575
1/2
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
124 if(!p_getc(&temp_map_count,f))
2576 {
2577 return qe_invalid;
2578 }
2579
2580
2/2
✓ Branch 0 taken 35 times.
✓ Branch 1 taken 89 times.
124 if(version>=4)
2581 {
2582
1/2
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
35 if(!p_igetl(&tempheader.new_version_id_main,f))
2583 {
2584 return qe_invalid;
2585 }
2586
1/2
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
35 if(!p_igetl(&tempheader.new_version_id_second,f))
2587 {
2588 return qe_invalid;
2589 }
2590
1/2
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
35 if(!p_igetl(&tempheader.new_version_id_third,f))
2591 {
2592 return qe_invalid;
2593 }
2594
1/2
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
35 if(!p_igetl(&tempheader.new_version_id_fourth,f))
2595 {
2596 return qe_invalid;
2597 }
2598
1/2
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
35 if(!p_igetl(&tempheader.new_version_id_alpha,f))
2599 {
2600 return qe_invalid;
2601 }
2602
1/2
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
35 if(!p_igetl(&tempheader.new_version_id_beta,f))
2603 {
2604 return qe_invalid;
2605 }
2606
1/2
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
35 if(!p_igetl(&tempheader.new_version_id_gamma,f))
2607 {
2608 return qe_invalid;
2609 }
2610
1/2
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
35 if(!p_igetl(&tempheader.new_version_id_release,f))
2611 {
2612 return qe_invalid;
2613 }
2614
1/2
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
35 if(!p_igetw(&tempheader.new_version_id_date_year,f))
2615 {
2616 return qe_invalid;
2617 }
2618
1/2
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
35 if(!p_getc(&tempheader.new_version_id_date_month,f))
2619 {
2620 return qe_invalid;
2621 }
2622
1/2
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
35 if(!p_getc(&tempheader.new_version_id_date_day,f))
2623 {
2624 return qe_invalid;
2625 }
2626
1/2
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
35 if(!p_getc(&tempheader.new_version_id_date_hour,f))
2627 {
2628 return qe_invalid;
2629 }
2630
1/2
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
35 if(!p_getc(&tempheader.new_version_id_date_minute,f))
2631 {
2632 return qe_invalid;
2633 }
2634
2635
1/2
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
35 if(!pfread(tempheader.new_version_devsig,256,f))
2636 {
2637 return qe_invalid;
2638 }
2639
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 35 times.
35 if(!strcmp(tempheader.new_version_devsig, "Venrob"))
2640 strcpy(tempheader.new_version_devsig, "EmilyV99");
2641
1/2
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
35 if(!pfread(tempheader.new_version_compilername,256,f))
2642 {
2643 return qe_invalid;
2644 }
2645
1/2
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
35 if(!pfread(tempheader.new_version_compilerversion,256,f))
2646 {
2647 return qe_invalid;
2648 }
2649
1/2
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
35 if(!pfread(tempheader.product_name,1024,f))
2650 {
2651 return qe_invalid;
2652 }
2653
2654
1/2
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
35 if(!p_getc(&tempheader.compilerid,f))
2655 {
2656 return qe_invalid;
2657 }
2658
1/2
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
35 if(!p_igetl(&tempheader.compilerversionnumber_first,f))
2659 {
2660 return qe_invalid;
2661 }
2662
1/2
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
35 if(!p_igetl(&tempheader.compilerversionnumber_second,f))
2663 {
2664 return qe_invalid;
2665 }
2666
1/2
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
35 if(!p_igetl(&tempheader.compilerversionnumber_third,f))
2667 {
2668 return qe_invalid;
2669 }
2670
1/2
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
35 if(!p_igetl(&tempheader.compilerversionnumber_fourth,f))
2671 {
2672 return qe_invalid;
2673 }
2674
1/2
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
35 if(!p_igetw(&tempheader.developerid,f))
2675 {
2676 return qe_invalid;
2677 }
2678
1/2
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
35 if(!pfread(tempheader.made_in_module_name,1024,f))
2679 {
2680 return qe_invalid;
2681 }
2682
1/2
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
35 if(!pfread(tempheader.build_datestamp,256,f))
2683 {
2684 return qe_invalid;
2685 }
2686
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 35 times.
35 if(!pfread(tempheader.build_timestamp,256,f))
2687 {
2688 return qe_invalid;
2689 }
2690 35 }
2691 else // <4
2692 {
2693 89 tempheader.new_version_id_main = 0;
2694 89 tempheader.new_version_id_second = 0;
2695 89 tempheader.new_version_id_third = 0;
2696 89 tempheader.new_version_id_fourth = 0;
2697 89 tempheader.new_version_id_alpha = 0;
2698 89 tempheader.new_version_id_beta = 0;
2699 89 tempheader.new_version_id_gamma = 0;
2700 89 tempheader.new_version_id_release = 0;
2701 89 tempheader.new_version_id_date_year = 0;
2702 89 tempheader.new_version_id_date_month = 0;
2703 89 tempheader.new_version_id_date_day = 0;
2704 89 tempheader.new_version_id_date_hour = 0;
2705 89 tempheader.new_version_id_date_minute = 0;
2706
2707 89 memset(tempheader.new_version_devsig, 0, 256);
2708 89 memset(tempheader.new_version_compilername, 0, 256);
2709 89 memset(tempheader.new_version_compilerversion, 0, 256);
2710 89 memset(tempheader.product_name, 0, 1024);
2711 89 strcpy(tempheader.product_name, "ZQuest Creator Suite");
2712
2713 89 tempheader.compilerid = 0;
2714 89 tempheader.compilerversionnumber_first = 0;
2715 89 tempheader.compilerversionnumber_second = 0;
2716 89 tempheader.compilerversionnumber_third = 0;
2717 89 tempheader.compilerversionnumber_fourth = 0;
2718 89 tempheader.developerid = 0;
2719
2720 89 memset(tempheader.made_in_module_name, 0, 1024);
2721 89 memset(tempheader.build_datestamp, 0, 256);
2722 89 memset(tempheader.build_timestamp, 0, 256);
2723 }
2724
2725
2/2
✓ Branch 0 taken 35 times.
✓ Branch 1 taken 89 times.
124 if ( version >= 5 )
2726 {
2727
1/2
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
35 if(!pfread(tempheader.build_timezone,6,f))
2728 {
2729 return qe_invalid;
2730 }
2731 35 }
2732 else // < 5
2733 {
2734 89 memset(tempheader.build_timezone, 0, 6);
2735 }
2736
2/2
✓ Branch 0 taken 89 times.
✓ Branch 1 taken 35 times.
124 if ( version >= 6 )
2737 {
2738 byte b;
2739
1/2
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
35 if(!p_getc(&b,f))
2740 {
2741 return qe_invalid;
2742 }
2743 35 tempheader.external_zinfo = b?true:false;
2744 35 read_zinfo = true;
2745 35 }
2746
2747
2/2
✓ Branch 0 taken 35 times.
✓ Branch 1 taken 89 times.
124 if(version >= 7)
2748 {
2749
1/2
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
35 if(!p_getc(&(tempheader.new_version_is_nightly),f))
2750 {
2751 return qe_invalid;
2752 }
2753 35 }
2754 else
2755 {
2756 89 tempheader.new_version_is_nightly = false;
2757
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 89 times.
89 if(tempheader.zelda_version < 0x255)
2758 {
2759
2/5
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 77 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 12 times.
89 switch(tempheader.zelda_version)
2760 {
2761 case 0x254:
2762 tempheader.new_version_id_main = 2;
2763 tempheader.new_version_id_second = 54;
2764 break;
2765 case 0x250:
2766
6/16
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✓ Branch 6 taken 22 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✓ Branch 10 taken 5 times.
✓ Branch 11 taken 24 times.
✗ Branch 12 not taken.
✓ Branch 13 taken 15 times.
✓ Branch 14 taken 10 times.
✓ Branch 15 taken 1 times.
77 switch(tempheader.build)
2767 {
2768 case 19:
2769 tempheader.new_version_id_main = 2;
2770 tempheader.new_version_id_second = 50;
2771 tempheader.new_version_id_gamma = 1;
2772 break;
2773 case 20:
2774 tempheader.new_version_id_main = 2;
2775 tempheader.new_version_id_second = 50;
2776 tempheader.new_version_id_gamma = 2;
2777 break;
2778 case 21:
2779 tempheader.new_version_id_main = 2;
2780 tempheader.new_version_id_second = 50;
2781 tempheader.new_version_id_gamma = 3;
2782 break;
2783 case 22:
2784 tempheader.new_version_id_main = 2;
2785 tempheader.new_version_id_second = 50;
2786 tempheader.new_version_id_gamma = 4;
2787 break;
2788 case 23:
2789 tempheader.new_version_id_main = 2;
2790 tempheader.new_version_id_second = 50;
2791 tempheader.new_version_id_gamma = 5;
2792 break;
2793 case 24:
2794 22 tempheader.new_version_id_main = 2;
2795 22 tempheader.new_version_id_second = 50;
2796 22 tempheader.new_version_id_release = -1;
2797 22 break;
2798 case 25:
2799 tempheader.new_version_id_main = 2;
2800 tempheader.new_version_id_second = 50;
2801 tempheader.new_version_id_third = 1;
2802 tempheader.new_version_id_gamma = 1;
2803 break;
2804 case 26:
2805 tempheader.new_version_id_main = 2;
2806 tempheader.new_version_id_second = 50;
2807 tempheader.new_version_id_third = 1;
2808 tempheader.new_version_id_gamma = 2;
2809 break;
2810 case 27:
2811 tempheader.new_version_id_main = 2;
2812 tempheader.new_version_id_second = 50;
2813 tempheader.new_version_id_third = 1;
2814 tempheader.new_version_id_gamma = 3;
2815 break;
2816 case 28:
2817 5 tempheader.new_version_id_main = 2;
2818 5 tempheader.new_version_id_second = 50;
2819 5 tempheader.new_version_id_third = 1;
2820 5 tempheader.new_version_id_release = -1;
2821 5 break;
2822 case 29:
2823 24 tempheader.new_version_id_main = 2;
2824 24 tempheader.new_version_id_second = 50;
2825 24 tempheader.new_version_id_third = 2;
2826 24 tempheader.new_version_id_release = -1;
2827 24 break;
2828 case 30:
2829 tempheader.new_version_id_main = 2;
2830 tempheader.new_version_id_second = 50;
2831 tempheader.new_version_id_third = 3;
2832 tempheader.new_version_id_gamma = 1;
2833 break;
2834 case 31:
2835 15 tempheader.new_version_id_main = 2;
2836 15 tempheader.new_version_id_second = 53;
2837 15 tempheader.new_version_id_gamma = -1;
2838 15 break;
2839 case 32:
2840 10 tempheader.new_version_id_main = 2;
2841 10 tempheader.new_version_id_second = 53;
2842 10 tempheader.new_version_id_release = -1;
2843 10 break;
2844 case 33:
2845 1 tempheader.new_version_id_main = 2;
2846 1 tempheader.new_version_id_second = 53;
2847 1 tempheader.new_version_id_third = 1;
2848 1 break;
2849 }
2850 77 break;
2851
2852 case 0x211:
2853 tempheader.new_version_id_main = 2;
2854 tempheader.new_version_id_second = 11;
2855 tempheader.new_version_id_beta = tempheader.build;
2856 break;
2857 case 0x210:
2858 12 tempheader.new_version_id_main = 2;
2859 12 tempheader.new_version_id_second = 10;
2860 12 tempheader.new_version_id_beta = tempheader.build;
2861 12 break;
2862 }
2863 89 }
2864 }
2865
2/4
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 124 times.
124 if(printmetadata || __isZQuest)
2866 {
2867 print_quest_metadata(tempheader, loading_qst_name, loading_qst_num);
2868 }
2869 }
2870
2871 //{ Version Warning
2872 128 int32_t vercmp = tempheader.compareVer();
2873 128 int32_t astatecmp = compare(int32_t(tempheader.getAlphaState()), ALPHA_STATE);
2874 128 int32_t avercmp = compare(tempheader.getAlphaVer(), ALPHA_VER);
2875
4/6
✓ Branch 0 taken 128 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 35 times.
✓ Branch 3 taken 93 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 35 times.
163 if(vercmp > 0 || (!vercmp &&
2876
2/4
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 35 times.
✗ Branch 3 not taken.
35 (astatecmp > 0 || (!astatecmp &&
2877 35 avercmp > 0))))
2878 {
2879 bool r = true;
2880 if(loadquest_report)
2881 {
2882 enter_sys_pal();
2883 AlertDialog("Quest saved in newer version",
2884 "This quest was last saved in a newer version of ZQuest."
2885 " Attempting to load this quest may not work correctly; to"
2886 " avoid issues, try loading this quest in at least '" + std::string(tempheader.getVerStr()) + "'"
2887 "\n\nWould you like to continue loading anyway? (Not recommended)",
2888 [&](bool ret,bool)
2889 {
2890 r = ret;
2891 }).show();
2892 exit_sys_pal();
2893 }
2894 if(!r)
2895 return qe_silenterr;
2896 }
2897
1/2
✓ Branch 0 taken 128 times.
✗ Branch 1 not taken.
128 else if(tempheader.compareDate() > 0)
2898 {
2899 bool r = true;
2900 if(loadquest_report)
2901 {
2902 enter_sys_pal();
2903 AlertDialog("Quest saved in newer build",
2904 fmt::format("This quest was last saved in a newer build of ZQuest, and may have"
2905 " issues loading in this build."
2906 "\n{}"
2907 "\n\nWould you like to continue loading anyway?",
2908 tempheader.getVerCmpStr()),
2909 [&](bool ret,bool)
2910 {
2911 r = ret;
2912 }).show();
2913 exit_sys_pal();
2914 }
2915 if(!r)
2916 return qe_silenterr;
2917 }
2918 //}
2919
2920 128 read_ext_zinfo = tempheader.external_zinfo;
2921
2922 128 memcpy(Header, &tempheader, sizeof(tempheader));
2923 128 map_count=temp_map_count;
2924 128 memcpy(midi_flags, temp_midi_flags, MIDIFLAGS_SIZE);
2925
2926 128 return 0;
2927 128 }
2928
2929 128 int32_t readrules(PACKFILE *f, zquestheader *Header)
2930 {
2931
2/2
✓ Branch 0 taken 124 times.
✓ Branch 1 taken 4 times.
128 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_rules);
2932
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 128 times.
128 if (should_skip)
2933 return 0;
2934
2935 int32_t dummy;
2936 zquestheader tempheader;
2937 128 word s_version=0;
2938 128 dword compatrule_version=0;
2939
2940 128 memcpy(&tempheader, Header, sizeof(tempheader));
2941
2942
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 124 times.
128 if(tempheader.zelda_version >= 0x193)
2943 {
2944 //section version info
2945
1/2
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
124 if(!p_igetw(&s_version,f))
2946 {
2947 return qe_invalid;
2948 }
2949
2950 124 FFCore.quest_format[vRules] = s_version;
2951
2952
1/2
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
124 if(!p_igetw(&dummy,f))
2953 {
2954 return qe_invalid;
2955 }
2956
2957
2/2
✓ Branch 0 taken 89 times.
✓ Branch 1 taken 35 times.
124 if(s_version > 16)
2958 {
2959
1/2
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
35 if(!p_igetl(&compatrule_version,f))
2960 {
2961 return qe_invalid;
2962 }
2963 35 }
2964 124 FFCore.quest_format[vCompatRule] = compatrule_version;
2965
2966 //section size
2967
1/2
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
124 if(!p_igetl(&dummy,f))
2968 {
2969 return qe_invalid;
2970 }
2971
2972
2/2
✓ Branch 0 taken 89 times.
✓ Branch 1 taken 35 times.
124 if ( s_version < 15 )
2973 {
2974 //finally... section data
2975
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 89 times.
89 if(!pfread(quest_rules,QUESTRULES_SIZE,f))
2976 {
2977 return qe_invalid;
2978 }
2979 89 }
2980 else
2981 {
2982
2983
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 35 times.
35 if(!pfread(quest_rules,QUESTRULES_NEW_SIZE,f))
2984 {
2985 return qe_invalid;
2986 }
2987
2988 }
2989 124 }
2990
2991 //al_trace("Rules version %d\n", s_version);
2992 //{ bunch of compat stuff
2993 128 memcpy(deprecated_rules, quest_rules, QUESTRULES_NEW_SIZE);
2994
2995
2/2
✓ Branch 0 taken 112 times.
✓ Branch 1 taken 16 times.
128 if(s_version<2)
2996 {
2997 16 set_qr(14,0);
2998 16 set_qr(27,0);
2999 16 set_qr(28,0);
3000 16 set_qr(29,0);
3001 16 set_qr(30,0);
3002 16 set_qr(32,0);
3003 16 set_qr(36,0);
3004 16 set_qr(49,0);
3005 16 set_qr(50,0);
3006 16 set_qr(51,0);
3007 16 set_qr(68,0);
3008 16 set_qr(75,0);
3009 16 set_qr(76,0);
3010 16 set_qr(98,0);
3011 16 set_qr(110,0);
3012 16 set_qr(113,0);
3013 16 set_qr(116,0);
3014 16 set_qr(102,0);
3015 16 set_qr(132,0);
3016 16 }
3017
3018 //Now, do any updates...
3019
3/6
✓ Branch 0 taken 112 times.
✓ Branch 1 taken 16 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 112 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
128 if((tempheader.zelda_version < 0x211)||((tempheader.zelda_version == 0x211)&&(tempheader.build<18)))
3020 {
3021 16 set_qr(qr_SMOOTHVERTICALSCROLLING,1);
3022 16 set_qr(qr_REPLACEOPENDOORS, 1);
3023 16 set_qr(qr_OLDLENSORDER, 1);
3024 16 set_qr(qr_NOFAIRYGUYFIRES, 1);
3025 16 set_qr(qr_TRIGGERSREPEAT, 1);
3026 16 }
3027
3028
3/6
✓ Branch 0 taken 124 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 124 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
128 if((tempheader.zelda_version < 0x193)||((tempheader.zelda_version == 0x193)&&(tempheader.build<3)))
3029 {
3030 4 set_qr(qr_WALLFLIERS,1);
3031 4 }
3032
3033
3/6
✓ Branch 0 taken 124 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 124 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
128 if((tempheader.zelda_version < 0x193)||((tempheader.zelda_version == 0x193)&&(tempheader.build<4)))
3034 {
3035 4 set_qr(qr_NOBOMBPALFLASH,1);
3036 4 }
3037
3038
5/6
✓ Branch 0 taken 124 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 124 times.
✓ Branch 4 taken 2 times.
✓ Branch 5 taken 2 times.
128 if((tempheader.zelda_version < 0x193)||((tempheader.zelda_version == 0x193)&&(tempheader.build<3)))
3039 {
3040 6 set_qr(qr_NOSCROLLCONTINUE,1);
3041 6 }
3042
3043
2/2
✓ Branch 0 taken 110 times.
✓ Branch 1 taken 16 times.
130 if(tempheader.zelda_version <= 0x210)
3044 {
3045 16 set_qr(qr_ARROWCLIP,1);
3046 16 }
3047
3048
2/2
✓ Branch 0 taken 114 times.
✓ Branch 1 taken 12 times.
126 if(tempheader.zelda_version == 0x210)
3049 {
3050 12 set_qr(qr_NOSCROLLCONTINUE, get_qr(qr_CMBCYCLELAYERS));
3051 12 set_qr(qr_CMBCYCLELAYERS, 0);
3052 12 set_qr(qr_CONT_SWORD_TRIGGERS, 1);
3053 12 }
3054
3055
2/2
✓ Branch 0 taken 110 times.
✓ Branch 1 taken 16 times.
126 if(tempheader.zelda_version <= 0x210)
3056 {
3057 16 set_qr(qr_OLDSTYLEWARP,1);
3058 16 set_qr(qr_210_WARPRETURN,1);
3059 16 }
3060
3061 //might not be correct
3062
2/2
✓ Branch 0 taken 122 times.
✓ Branch 1 taken 4 times.
126 if(tempheader.zelda_version < 0x210)
3063 {
3064 4 set_bit(deprecated_rules, qr_OLDTRIBBLES_DEP,1);
3065 4 set_qr(qr_OLDTRIBBLES_DEP,1);
3066 4 set_qr(qr_OLDHOOKSHOTGRAB,1);
3067 4 }
3068
3069
2/2
✓ Branch 0 taken 110 times.
✓ Branch 1 taken 16 times.
126 if(tempheader.zelda_version < 0x211)
3070 {
3071 16 set_qr(qr_WRONG_BRANG_TRAIL_DIR,1);
3072 16 }
3073
3074
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 126 times.
✓ Branch 2 taken 4 times.
✓ Branch 3 taken 122 times.
126 if((tempheader.zelda_version == 0x192 && tempheader.build <= 163) || tempheader.zelda_version < 0x192)
3075 {
3076 4 set_qr(qr_192b163_WARP,1);
3077 4 }
3078
3079
2/2
✓ Branch 0 taken 114 times.
✓ Branch 1 taken 12 times.
126 if(tempheader.zelda_version == 0x210)
3080 {
3081 12 set_bit(deprecated_rules, qr_OLDTRIBBLES_DEP, get_qr(qr_DMGCOMBOPRI));
3082 12 set_qr(qr_OLDTRIBBLES_DEP, get_qr(qr_DMGCOMBOPRI));
3083 12 set_qr(qr_DMGCOMBOPRI, 0);
3084 12 }
3085
3086
5/6
✓ Branch 0 taken 112 times.
✓ Branch 1 taken 14 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 112 times.
✓ Branch 4 taken 2 times.
✓ Branch 5 taken 2 times.
126 if(tempheader.zelda_version < 0x211 || (tempheader.zelda_version == 0x211 && tempheader.build<15))
3087 {
3088 16 set_qr(qr_OLDPICKUP,1);
3089 16 }
3090
3091
5/6
✓ Branch 0 taken 112 times.
✓ Branch 1 taken 14 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 112 times.
✓ Branch 4 taken 2 times.
✓ Branch 5 taken 2 times.
130 if(tempheader.zelda_version < 0x211 || (tempheader.zelda_version == 0x211 && tempheader.build < 18))
3092 {
3093 16 set_qr(qr_NOSOLIDDAMAGECOMBOS, 1);
3094 16 set_qr(qr_ITEMPICKUPSETSBELOW, 1); // broke around build 400
3095 16 }
3096
3097
2/2
✓ Branch 0 taken 110 times.
✓ Branch 1 taken 16 times.
130 if(tempheader.zelda_version < 0x250) // version<0x250 checks for beta 18; build was set to 18 prematurely
3098 {
3099 16 set_qr(qr_HOOKSHOTDOWNBUG, 1);
3100 16 }
3101
3102
4/4
✓ Branch 0 taken 77 times.
✓ Branch 1 taken 49 times.
✓ Branch 2 taken 55 times.
✓ Branch 3 taken 22 times.
126 if(tempheader.zelda_version == 0x250 && tempheader.build == 24) // Annoying...
3103 {
3104 22 set_qr(qr_PEAHATCLOCKVULN, 1);
3105 22 }
3106
3107
6/6
✓ Branch 0 taken 112 times.
✓ Branch 1 taken 14 times.
✓ Branch 2 taken 77 times.
✓ Branch 3 taken 35 times.
✓ Branch 4 taken 2 times.
✓ Branch 5 taken 75 times.
126 if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build < 22)) //22 is 2.50.0 RC4. Gotta set the door repair QR... -Dimi
3108 {
3109 16 set_qr(qr_OLD_DOORREPAIR, 1);
3110 16 }
3111
3112
6/6
✓ Branch 0 taken 112 times.
✓ Branch 1 taken 14 times.
✓ Branch 2 taken 77 times.
✓ Branch 3 taken 35 times.
✓ Branch 4 taken 2 times.
✓ Branch 5 taken 79 times.
126 if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build < 20)) //20 is 2.50.0 RC1 and RC2 (cause it didn't get bumped). Okay I'm gonna be honest I have no idea if any 2.50 build was available before RC1, but gonna try and cover my ass here -Dimi
3113 {
3114 16 set_qr(qr_OLD_SECRETMONEY, 1);
3115 16 }
3116
3117
6/6
✓ Branch 0 taken 112 times.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 77 times.
✓ Branch 3 taken 35 times.
✓ Branch 4 taken 20 times.
✓ Branch 5 taken 57 times.
130 if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build < 28)) //28 is 2.50.1 final. Potion bug might have been used, I dunno. -Dimi
3118 {
3119 38 set_qr(qr_OLD_POTION_OR_HC, 1);
3120 38 }
3121
3122
6/6
✓ Branch 0 taken 112 times.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 77 times.
✓ Branch 3 taken 35 times.
✓ Branch 4 taken 20 times.
✓ Branch 5 taken 57 times.
130 if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build<28))
3123 {
3124 38 set_qr(qr_OFFSCREENWEAPONS, 1);
3125 38 }
3126
3127 //Bombchu fix.
3128
2/2
✓ Branch 0 taken 53 times.
✓ Branch 1 taken 77 times.
130 if(tempheader.zelda_version == 0x250)
3129 {
3130
2/2
✓ Branch 0 taken 55 times.
✓ Branch 1 taken 22 times.
77 if ( tempheader.build == 24 ) //2.50.0
3131 {
3132 22 set_qr(qr_BOMBCHUSUPERBOMB, 1);
3133 22 }
3134
2/2
✓ Branch 0 taken 72 times.
✓ Branch 1 taken 5 times.
77 if ( tempheader.build == 28 ) //2.50.1
3135 {
3136 5 set_qr(qr_BOMBCHUSUPERBOMB, 1);
3137 5 }
3138
2/2
✓ Branch 0 taken 53 times.
✓ Branch 1 taken 24 times.
77 if ( tempheader.build == 29 ) //2.50.2
3139 {
3140 24 set_qr(qr_BOMBCHUSUPERBOMB, 0);
3141 24 }
3142
1/2
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
77 if ( tempheader.build == 30 ) //2.50.3RC1
3143 {
3144 set_qr(qr_BOMBCHUSUPERBOMB, 0);
3145 }
3146 77 }
3147
3148
6/6
✓ Branch 0 taken 112 times.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 77 times.
✓ Branch 3 taken 35 times.
✓ Branch 4 taken 25 times.
✓ Branch 5 taken 52 times.
130 if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build<29))
3149 {
3150 // qr_OFFSETEWPNCOLLISIONFIX
3151 // All 'official' quests need this disabled.
3152 // All 2.10 and lower quests need this enabled to preseve compatability.
3153 // All 2.11 - 2.5.1 quests should have it set also, due to a bug in about half of all the betas.
3154
3155 //~Gleeok
3156 43 set_qr(qr_OFFSETEWPNCOLLISIONFIX, 1); //This has to be set!!!!
3157
3158 // Broke in build 695
3159
3/4
✓ Branch 0 taken 27 times.
✓ Branch 1 taken 16 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 27 times.
43 if(tempheader.zelda_version>=0x211 && tempheader.build>=18)
3160 27 set_qr(qr_BROKENSTATUES, 1);
3161 43 }
3162
2/2
✓ Branch 0 taken 126 times.
✓ Branch 1 taken 4 times.
130 if (tempheader.zelda_version <= 0x190)
3163 {
3164 4 set_qr(qr_COPIED_SWIM_SPRITES, 1);
3165 4 }
3166
9/10
✓ Branch 0 taken 77 times.
✓ Branch 1 taken 53 times.
✓ Branch 2 taken 52 times.
✓ Branch 3 taken 1 times.
✓ Branch 4 taken 36 times.
✓ Branch 5 taken 16 times.
✓ Branch 6 taken 35 times.
✓ Branch 7 taken 1 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 35 times.
130 if ( (tempheader.zelda_version == 0x250 && tempheader.build < 33) || tempheader.zelda_version == 0x254 || tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x255 && tempheader.build < 50) )
3167 {
3168 94 set_qr(qr_OLD_SLASHNEXT_SECRETS, 1);
3169 94 }
3170
3171
2/2
✓ Branch 0 taken 112 times.
✓ Branch 1 taken 16 times.
128 if ( (tempheader.zelda_version < 0x211) ) //2.10 water and ladder interaction
3172 {
3173 16 set_qr(qr_OLD_210_WATER, 1);
3174 16 }
3175
3176
4/6
✓ Branch 0 taken 35 times.
✓ Branch 1 taken 93 times.
✓ Branch 2 taken 35 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 35 times.
128 if ( (tempheader.zelda_version < 0x255 ) || (tempheader.zelda_version == 0x255 && tempheader.build < 51 ) ) //2.10 water and ladder interaction
3177 {
3178 93 set_qr(qr_STEP_IS_FLOAT,0);
3179 93 }
3180
3181
2/2
✓ Branch 0 taken 112 times.
✓ Branch 1 taken 16 times.
128 if ( tempheader.zelda_version < 0x250 )
3182 {
3183 16 set_qr(qr_8WAY_SHOT_SFX, 1);
3184 16 }
3185
3186
2/2
✓ Branch 0 taken 112 times.
✓ Branch 1 taken 16 times.
128 if(s_version < 3)
3187 {
3188 16 set_qr(qr_HOLDNOSTOPMUSIC, 1);
3189 16 set_qr(qr_CAVEEXITNOSTOPMUSIC, 1);
3190 16 }
3191
3192
2/2
✓ Branch 0 taken 112 times.
✓ Branch 1 taken 16 times.
128 if(s_version<4)
3193 {
3194 16 set_qr(10,0);
3195 16 }
3196
3197
2/2
✓ Branch 0 taken 112 times.
✓ Branch 1 taken 16 times.
128 if(s_version<5)
3198 {
3199 16 set_qr(27,0);
3200 16 }
3201
3202
2/2
✓ Branch 0 taken 112 times.
✓ Branch 1 taken 16 times.
128 if(s_version<6)
3203 {
3204 16 set_qr(46,0);
3205 16 }
3206
3207
2/2
✓ Branch 0 taken 112 times.
✓ Branch 1 taken 16 times.
128 if(s_version<7) // January 2008
3208 {
3209 16 set_qr(qr_HEARTSREQUIREDFIX,0);
3210 16 set_qr(qr_PUSHBLOCKCSETFIX,1);
3211 16 }
3212
3213
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 112 times.
128 if(s_version<8)
3214 {
3215 16 set_qr(12, 0);
3216 16 }
3217 else
3218 {
3219 112 set_bit(deprecated_rules, 12, 0);
3220 }
3221
3222
2/2
✓ Branch 0 taken 112 times.
✓ Branch 1 taken 16 times.
128 if(s_version<9) // October 2008
3223 {
3224 16 set_qr(qr_NOROPE2FLASH_DEP,0);
3225 16 set_qr(qr_NOBUBBLEFLASH_DEP,0);
3226 16 set_qr(qr_GHINI2BLINK_DEP,0);
3227 16 set_qr(qr_PHANTOMGHINI2_DEP,0);
3228 16 }
3229
3230
2/2
✓ Branch 0 taken 112 times.
✓ Branch 1 taken 16 times.
128 if(s_version<10) // December 2008
3231 {
3232 16 set_qr(qr_NOCLOCKS_DEP,0);
3233 16 set_qr(qr_ALLOW10RUPEEDROPS_DEP,0);
3234 16 }
3235
3236
2/2
✓ Branch 0 taken 112 times.
✓ Branch 1 taken 16 times.
128 if(s_version<11) // April 2009
3237 {
3238 16 set_qr(qr_SLOWENEMYANIM_DEP,0);
3239 16 }
3240
3241 // This served no purpose.
3242 // if(s_version<12) // December 2009
3243 // {
3244 // set_qr(qr_BRKBLSHLDS_DEP,0);
3245 // set_qr(qr_OLDTRIBBLES_DEP,0);
3246 // }
3247
3248 //if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build < 24))
3249
2/2
✓ Branch 0 taken 112 times.
✓ Branch 1 taken 16 times.
128 if(s_version < 13)
3250 {
3251 16 set_qr(qr_SHOPCHEAT, 1);
3252 16 }
3253
3254 // Not entirely sure this is the best place for this...
3255 //2.50.2 bitmap offset fix
3256 128 memset(extra_rules, 0, EXTRARULES_SIZE);
3257
6/6
✓ Branch 0 taken 112 times.
✓ Branch 1 taken 16 times.
✓ Branch 2 taken 77 times.
✓ Branch 3 taken 35 times.
✓ Branch 4 taken 27 times.
✓ Branch 5 taken 50 times.
128 if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build<29))
3258 {
3259 43 set_er(er_BITMAPOFFSET, 1);
3260 43 set_qr(qr_BITMAPOFFSETFIX, 1);
3261 43 }
3262 //required because quest templates also used this bit, although
3263 //it never did anything, before. -Z
3264
2/2
✓ Branch 0 taken 51 times.
✓ Branch 1 taken 77 times.
128 if ( tempheader.zelda_version == 0x250 )
3265 {
3266
5/6
✓ Branch 0 taken 53 times.
✓ Branch 1 taken 24 times.
✓ Branch 2 taken 53 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 15 times.
✓ Branch 5 taken 38 times.
77 if( tempheader.build == 29 || tempheader.build == 30 || tempheader.build == 31 )
3267 {
3268 39 set_er(er_BITMAPOFFSET, 0);
3269 39 set_qr(qr_BITMAPOFFSETFIX, 0);
3270 39 }
3271 77 }
3272
1/2
✓ Branch 0 taken 128 times.
✗ Branch 1 not taken.
128 if ( tempheader.zelda_version == 0x254 )
3273 {
3274 set_er(er_BITMAPOFFSET, 0);
3275 set_qr(qr_BITMAPOFFSETFIX, 0);
3276 }
3277
3/4
✓ Branch 0 taken 35 times.
✓ Branch 1 taken 93 times.
✓ Branch 2 taken 35 times.
✗ Branch 3 not taken.
128 if ( tempheader.zelda_version == 0x255 && tempheader.build < 42 ) //QR was added to 255 in this build.
3278 {
3279 set_er(er_BITMAPOFFSET, 0);
3280 set_qr(qr_BITMAPOFFSETFIX, 0);
3281 }
3282 //optimise fast drawing for older versions.
3283
4/6
✓ Branch 0 taken 35 times.
✓ Branch 1 taken 93 times.
✓ Branch 2 taken 35 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 35 times.
128 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 42) )
3284 {
3285 93 set_qr(qr_OLDSPRITEDRAWS, 1);
3286 93 }
3287 //Old eweapon->Parent (was added in 2.54, Alpha 19)
3288 //The change was made in build 43, but I'm setting this to < 42, because quests made in 42 would benefit from this change, and
3289 //older quests can set the rule by hand. We need a new qst.dat again.
3290
4/6
✓ Branch 0 taken 128 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 35 times.
✓ Branch 3 taken 93 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 35 times.
128 if ( tempheader.zelda_version == 0x254 || (tempheader.zelda_version == 0x255 && tempheader.build < 42) )
3291 {
3292 set_qr(qr_OLDEWPNPARENT, 1);
3293 }
3294
4/6
✓ Branch 0 taken 128 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 35 times.
✓ Branch 3 taken 93 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 35 times.
128 if ( tempheader.zelda_version == 0x254 || (tempheader.zelda_version == 0x255 && tempheader.build < 44) )
3295 {
3296 set_qr(qr_OLDCREATEBITMAP_ARGS, 1);
3297 }
3298
4/6
✓ Branch 0 taken 128 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 35 times.
✓ Branch 3 taken 93 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 35 times.
128 if ( tempheader.zelda_version == 0x254 || (tempheader.zelda_version == 0x255 && tempheader.build < 45) )
3299 {
3300 set_qr(qr_OLDQUESTMISC, 1);
3301 }
3302
2/2
✓ Branch 0 taken 35 times.
✓ Branch 1 taken 93 times.
128 if ( tempheader.zelda_version < 0x254 )
3303 {
3304 93 set_qr(qr_OLDCREATEBITMAP_ARGS, 0);
3305 93 set_qr(qr_OLDEWPNPARENT, 0);
3306 93 set_qr(qr_OLDQUESTMISC, 0);
3307 93 }
3308
3309 //item scripts continue to run
3310
4/6
✓ Branch 0 taken 35 times.
✓ Branch 1 taken 93 times.
✓ Branch 2 taken 35 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 35 times.
128 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 44) )
3311 {
3312 93 set_qr(qr_ITEMSCRIPTSKEEPRUNNING, 0);
3313 93 set_qr(qr_SCRIPTSRUNINHEROSTEPFORWARD, 0);
3314 93 set_qr(qr_FIXSCRIPTSDURINGSCROLLING, 0);
3315 93 set_qr(qr_SCRIPTDRAWSINWARPS, 0);
3316 93 set_qr(qr_DYINGENEMYESDONTHURTHERO, 0);
3317 93 set_qr(qr_OUTOFBOUNDSENEMIES, 0);
3318 93 set_qr(qr_SPRITEXY_IS_FLOAT, 0);
3319 93 }
3320
3321
4/6
✓ Branch 0 taken 35 times.
✓ Branch 1 taken 93 times.
✓ Branch 2 taken 35 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 35 times.
128 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 46) )
3322 {
3323 93 set_qr(qr_CLEARINITDONSCRIPTCHANGE, 1);
3324 93 }
3325
4/6
✓ Branch 0 taken 35 times.
✓ Branch 1 taken 93 times.
✓ Branch 2 taken 35 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 35 times.
128 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 46) )
3326 {
3327 93 set_qr(qr_TRACESCRIPTIDS, 0);
3328 93 set_qr(qr_SCRIPT_FRIENDLY_ENEMY_TYPES, 1);
3329 93 set_qr(qr_PARSER_BOOL_TRUE_DECIMAL, 1);
3330 93 set_qr(qr_PARSER_250DIVISION,1);
3331 93 set_qr(qr_PARSER_BOOL_TRUE_DECIMAL,1);
3332 93 set_qr(qr_PARSER_TRUE_INT_SIZE,0);
3333 93 set_qr(qr_PARSER_FORCE_INLINE,0);
3334 93 set_qr(qr_PARSER_BINARY_32BIT,0);
3335
2/2
✓ Branch 0 taken 91 times.
✓ Branch 1 taken 2 times.
93 if ( get_qr(qr_SELECTAWPN) )
3336 {
3337 2 set_qr(qr_NO_L_R_BUTTON_INVENTORY_SWAP,1);
3338 //In < 2.55a27, if you had an A+B subscreen, L and R didn't shift through inventory.
3339 //Now they **do**, unless you disable that behaviour.
3340 //For the sake of compatibility, old quests with the A+B subscreen rule enabed
3341 //now enable the disable L/R item swap on load.
3342 2 }
3343
3344 93 }
3345
4/6
✓ Branch 0 taken 35 times.
✓ Branch 1 taken 93 times.
✓ Branch 2 taken 35 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 35 times.
128 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 47) )
3346 {
3347 //Compatibility: Setting the hero's action to rafting was previously disallowed, though legal for scripts to attempt.
3348 93 set_qr(qr_DISALLOW_SETTING_RAFTING, 1);
3349 //Compatibility: The calculation for when to loop an animation did not factor in ASkipY correctly, resulting in
3350 //animations ending earlier than they should.
3351 93 set_qr(qr_BROKEN_ASKIP_Y_FRAMES, 1);
3352 //Enemies would ignore solidity on the top half of combos
3353 93 set_qr(qr_ENEMY_BROKEN_TOP_HALF_SOLIDITY, 1);
3354 //Ceiling collison was a bit wonky, including hitting your head before you are near the ceiling or clipping into it slightly.
3355 93 set_qr(qr_OLD_SIDEVIEW_CEILING_COLLISON, 1);
3356 //If an itemdata had a 'frames' of 0, items created of that data would ignore all changes to 'frames'
3357 93 set_qr(qr_0AFRAME_ITEMS_IGNORE_AFRAME_CHANGES, 1);
3358 //Collision used some odd calculations before, and enemies could not be hit back into the top row or left column
3359 93 set_qr(qr_OLD_ENEMY_KNOCKBACK_COLLISION, 1);
3360 93 }
3361
2/2
✓ Branch 0 taken 35 times.
✓ Branch 1 taken 93 times.
128 if ( tempheader.zelda_version < 0x255 )
3362 {
3363 93 set_qr(qr_NOFFCWAITDRAW, 1);
3364 93 set_qr(qr_NOITEMWAITDRAW, 1);
3365 93 set_qr(qr_SETENEMYWEAPONSPRITESONWPNCHANGE, 1);
3366 93 set_qr(qr_OLD_INIT_SCRIPT_TIMING, 1);
3367 //set_qr(qr_DO_NOT_DEALLOCATE_INIT_AND_SAVELOAD_ARRAYS, 1);
3368 93 }
3369
4/6
✓ Branch 0 taken 35 times.
✓ Branch 1 taken 93 times.
✓ Branch 2 taken 35 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 35 times.
128 if ( tempheader.zelda_version < 0x255 || ( tempheader.zelda_version == 0x255 && tempheader.build < 48 ) )
3370 {
3371 93 set_qr(qr_SETENEMYWEAPONSPRITESONWPNCHANGE, 1);
3372 93 }
3373
4/6
✓ Branch 0 taken 35 times.
✓ Branch 1 taken 93 times.
✓ Branch 2 taken 35 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 35 times.
128 if( tempheader.zelda_version < 0x255 || ( tempheader.zelda_version == 0x255 && tempheader.build < 52 ) )
3374 {
3375 93 set_qr(qr_OLD_PRINTF_ARGS, 1);
3376 93 }
3377
3378
3379
4/6
✓ Branch 0 taken 35 times.
✓ Branch 1 taken 93 times.
✓ Branch 2 taken 35 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 35 times.
128 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 54) )
3380 {
3381 93 set_qr(qr_BROKEN_RING_POWER, 1);
3382 93 }
3383
4/6
✓ Branch 0 taken 35 times.
✓ Branch 1 taken 93 times.
✓ Branch 2 taken 35 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 35 times.
128 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 56) )
3384 {
3385 93 set_qr(qr_NO_OVERWORLD_MAP_CHARTING, 1);
3386 93 }
3387
4/6
✓ Branch 0 taken 35 times.
✓ Branch 1 taken 93 times.
✓ Branch 2 taken 35 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 35 times.
128 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 57) )
3388 {
3389 93 set_qr(qr_DUNGEONS_USE_CLASSIC_CHARTING, 1);
3390 93 }
3391
4/6
✓ Branch 0 taken 35 times.
✓ Branch 1 taken 93 times.
✓ Branch 2 taken 35 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 35 times.
128 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 58) )
3392 {
3393 //Rule used to be 'qr_SETXYBUTTONITEMS', now split.
3394
1/2
✓ Branch 0 taken 93 times.
✗ Branch 1 not taken.
93 if(get_qr(qr_SET_XBUTTON_ITEMS))
3395 set_qr(qr_SET_YBUTTON_ITEMS,1);
3396 93 }
3397
4/6
✓ Branch 0 taken 35 times.
✓ Branch 1 taken 93 times.
✓ Branch 2 taken 35 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 35 times.
128 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 59) )
3398 {
3399 93 set_qr(qr_ALLOW_EDITING_COMBO_0,1);
3400 93 }
3401
4/6
✓ Branch 0 taken 35 times.
✓ Branch 1 taken 93 times.
✓ Branch 2 taken 35 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 35 times.
128 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 60) )
3402 {
3403 93 set_qr(qr_OLD_CHEST_COLLISION,1);
3404 93 }
3405
3406
2/2
✓ Branch 0 taken 35 times.
✓ Branch 1 taken 93 times.
128 if ( tempheader.zelda_version < 0x254 )
3407 {
3408 93 set_qr(qr_250WRITEEDEFSCRIPT, 1);
3409 93 }
3410 //Sideview spikes in 2.50.0
3411
6/6
✓ Branch 0 taken 112 times.
✓ Branch 1 taken 16 times.
✓ Branch 2 taken 77 times.
✓ Branch 3 taken 35 times.
✓ Branch 4 taken 22 times.
✓ Branch 5 taken 55 times.
128 if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build<27)) //2.50.1RC3
3412 {
3413 38 set_qr(qr_OLDSIDEVIEWSPIKES, 1);
3414 38 }
3415 //more 2.50 fixes -Z
3416
6/6
✓ Branch 0 taken 112 times.
✓ Branch 1 taken 16 times.
✓ Branch 2 taken 77 times.
✓ Branch 3 taken 35 times.
✓ Branch 4 taken 51 times.
✓ Branch 5 taken 26 times.
128 if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build<31))
3417 {
3418 67 set_qr(qr_MELEEMAGICCOST, 0);
3419 67 set_qr(qr_GANONINTRO, 0); //This will get flipped later on in the compatrule 11 check. That's why it's turning it off.
3420 67 set_qr(qr_OLDMIRRORCOMBOS, 1);
3421 67 set_qr(qr_BROKENBOOKCOST, 1);
3422 67 set_qr(qr_BROKENCHARINTDRAWING, 1);
3423
3424 67 }
3425
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 128 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
128 if(tempheader.zelda_version == 0x254 && tempheader.build<41)
3426 {
3427 //set_qr(qr_MELEEMAGICCOST, get_er(er_MAGICCOSTSWORD));
3428 set_qr(qr_MELEEMAGICCOST, 1);
3429 }
3430
3431
2/2
✓ Branch 0 taken 124 times.
✓ Branch 1 taken 4 times.
128 if(tempheader.zelda_version < 0x193)
3432 {
3433 4 set_qr(qr_SHORTDGNWALK, 1);
3434 4 }
3435
3436
2/2
✓ Branch 0 taken 35 times.
✓ Branch 1 taken 93 times.
128 if(tempheader.zelda_version < 0x255)
3437 {
3438 93 set_qr(qr_OLDINFMAGIC, 1);
3439 93 }
3440
3441
2/2
✓ Branch 0 taken 112 times.
✓ Branch 1 taken 16 times.
128 if((tempheader.zelda_version < 0x250)) //2.10 and earlier allowed the triforce to Warp Player out of Item Cellars in Dungeons. -Z (15th March, 2019 )
3442 {
3443 16 set_qr(qr_SIDEVIEWTRIFORCECELLAR,1);
3444 16 }
3445
3446
4/6
✓ Branch 0 taken 35 times.
✓ Branch 1 taken 93 times.
✓ Branch 2 taken 35 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 35 times.
128 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 47) )
3447 {
3448 93 set_qr(qr_OLD_F6,1);
3449 93 }
3450
4/6
✓ Branch 0 taken 35 times.
✓ Branch 1 taken 93 times.
✓ Branch 2 taken 35 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 35 times.
128 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 49) )
3451 {
3452 93 set_qr(qr_NO_OVERWRITING_HOPPING,1);
3453 93 }
3454
4/6
✓ Branch 0 taken 35 times.
✓ Branch 1 taken 93 times.
✓ Branch 2 taken 35 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 35 times.
128 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 50) )
3455 {
3456 93 set_qr(qr_STRING_FRAME_OLD_WIDTH_HEIGHT,1);
3457 93 }
3458
4/6
✓ Branch 0 taken 35 times.
✓ Branch 1 taken 93 times.
✓ Branch 2 taken 35 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 35 times.
128 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 53) )
3459 {
3460 93 set_qr(qr_BROKEN_OVERWORLD_MINIMAP,1);
3461 93 }
3462 //}
3463
3464
2/2
✓ Branch 0 taken 35 times.
✓ Branch 1 taken 93 times.
128 if(compatrule_version < 1) //Enemies->Secret only affects flag 16-31
3465 93 set_qr(qr_ENEMIES_SECRET_ONLY_16_31,1);
3466
3467
2/2
✓ Branch 0 taken 35 times.
✓ Branch 1 taken 93 times.
128 if(compatrule_version < 2) //Old CSet2 Handling
3468 93 set_qr(qr_OLDCS2,1);
3469
3470
2/2
✓ Branch 0 taken 35 times.
✓ Branch 1 taken 93 times.
128 if(compatrule_version < 3) //Hardcoded Shadow/Spawn/Death anim frames
3471 93 set_qr(qr_HARDCODED_ENEMY_ANIMS,1);
3472
3473
2/2
✓ Branch 0 taken 35 times.
✓ Branch 1 taken 93 times.
128 if(compatrule_version < 4) //Hardcoded Shadow/Spawn/Death anim frames
3474 93 set_qr(qr_OLD_ITEMDATA_SCRIPT_TIMING,1);
3475
3476
4/4
✓ Branch 0 taken 93 times.
✓ Branch 1 taken 35 times.
✓ Branch 2 taken 16 times.
✓ Branch 3 taken 77 times.
128 if(compatrule_version < 5 && tempheader.zelda_version >= 0x250) //Hardcoded Shadow/Spawn/Death anim frames
3477 77 set_qr(qr_NO_LANMOLA_RINGLEADER,1);
3478
3479
2/2
✓ Branch 0 taken 35 times.
✓ Branch 1 taken 93 times.
128 if(compatrule_version < 6) //Step->Secret (Temp) only affects flag 16-31
3480 93 set_qr(qr_STEPTEMP_SECRET_ONLY_16_31,1);
3481
3482
2/2
✓ Branch 0 taken 35 times.
✓ Branch 1 taken 93 times.
128 if(compatrule_version < 7) //'Hit All Triggers->Perm Secret' doesn't trigger temp secrets
3483 93 set_qr(qr_ALLTRIG_PERMSEC_NO_TEMP,1);
3484
3485
2/2
✓ Branch 0 taken 35 times.
✓ Branch 1 taken 93 times.
128 if(compatrule_version < 8) //Hardcoded LItem/Bomb/Clock/Magic Tile Mods
3486 93 set_qr(qr_HARDCODED_LITEM_LTMS,1);
3487
3488
2/2
✓ Branch 0 taken 35 times.
✓ Branch 1 taken 93 times.
128 if(compatrule_version < 9)
3489 {
3490 //Hardcoded BS Patras
3491 93 set_qr(qr_HARDCODED_BS_PATRA,1);
3492 //Hardcoded Patra Inner Eye offsets
3493 93 set_qr(qr_PATRAS_USE_HARDCODED_OFFSETS,1);
3494 //Broken 'Big enemy' animation style
3495 93 set_qr(qr_BROKEN_BIG_ENEMY_ANIMATION,1);
3496 //Broken Attribute 31/32
3497 93 set_qr(qr_BROKEN_ATTRIBUTE_31_32,1);
3498 93 }
3499
3500
2/2
✓ Branch 0 taken 35 times.
✓ Branch 1 taken 93 times.
128 if(compatrule_version < 10) //Shared candle use limits
3501 93 set_qr(qr_CANDLES_SHARED_LIMIT,1);
3502
3503
2/2
✓ Branch 0 taken 35 times.
✓ Branch 1 taken 93 times.
128 if(compatrule_version < 11) //No cross-screen return points
3504 93 set_qr(qr_OLD_RESPAWN_POINTS,1);
3505
3506
2/2
✓ Branch 0 taken 35 times.
✓ Branch 1 taken 93 times.
128 if(compatrule_version < 12)
3507 {
3508 //Old fire trail duration
3509 93 set_qr(qr_OLD_FLAMETRAIL_DURATION,1);
3510 //Old Intro String in Ganon Room Behavior
3511
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 93 times.
93 if(get_qr(qr_GANONINTRO)) set_qr(qr_GANONINTRO,0);
3512 93 else set_qr(qr_GANONINTRO,1);
3513 93 }
3514
3515
3/4
✓ Branch 0 taken 93 times.
✓ Branch 1 taken 35 times.
✓ Branch 2 taken 93 times.
✗ Branch 3 not taken.
128 if(compatrule_version < 13 && tempheader.zelda_version >= 0x255) //ANone doesn't reset to originaltile
3516 set_qr(qr_ANONE_NOANIM,1);
3517
3518
2/2
✓ Branch 0 taken 35 times.
✓ Branch 1 taken 93 times.
128 if(compatrule_version < 14) //Old Bridge Combo Behavior
3519 93 set_qr(qr_OLD_BRIDGE_COMBOS,1);
3520
3521
2/2
✓ Branch 0 taken 35 times.
✓ Branch 1 taken 93 times.
128 if(compatrule_version < 15) //Broken Z3 Animation
3522 93 set_qr(qr_BROKEN_Z3_ANIMATION,1);
3523
3524
2/2
✓ Branch 0 taken 35 times.
✓ Branch 1 taken 93 times.
128 if(compatrule_version < 16) //Old Enemy Tile Behavior with Animation (None) Enemies
3525 93 set_qr(qr_OLD_TILE_INITIALIZATION,1);
3526
3527
2/2
✓ Branch 0 taken 35 times.
✓ Branch 1 taken 93 times.
128 if(compatrule_version < 17)
3528 {
3529 //Old Quake/DrawYOffset behavior
3530 //set_qr(qr_OLD_DRAWOFFSET,1);
3531 //I'm leaving this commented cause I doubt it'll break anything and I think the bugfix might be appreciated in older versions.
3532 //On the offchance that it *does* break old quests, fixing it is as simple as uncommenting the set_bit above.
3533 93 }
3534
3535
2/2
✓ Branch 0 taken 35 times.
✓ Branch 1 taken 93 times.
128 if(compatrule_version < 18)
3536 {
3537 //Broken DrawScreen Derivative Functions
3538 93 set_qr(qr_BROKEN_DRAWSCREEN_FUNCTIONS,1);
3539 //Scrolling Cancels Charge
3540 93 set_qr(qr_SCROLLING_KILLS_CHARGE,1);
3541 93 }
3542
3543
2/2
✓ Branch 0 taken 35 times.
✓ Branch 1 taken 93 times.
128 if(compatrule_version < 19) //Broken Enemy Item Carrying with Large Enemies
3544 93 set_qr(qr_BROKEN_ITEM_CARRYING,1);
3545
3546
2/2
✓ Branch 0 taken 35 times.
✓ Branch 1 taken 93 times.
128 if(compatrule_version < 20)
3547 93 set_qr(qr_CUSTOMWEAPON_IGNORE_COST,1);
3548
3549
2/2
✓ Branch 0 taken 35 times.
✓ Branch 1 taken 93 times.
128 if(compatrule_version < 21)
3550 {
3551 93 set_qr(qr_LEEVERS_DONT_OBEY_STUN,1);
3552 93 set_qr(qr_GANON_CANT_SPAWN_ON_CONTINUE,1);
3553 93 set_qr(qr_WIZZROBES_DONT_OBEY_STUN,1);
3554 93 set_qr(qr_OLD_BUG_NET,1);
3555 93 set_qr(qr_MANHANDLA_BLOCK_SFX,1);
3556 93 }
3557
3558
2/2
✓ Branch 0 taken 35 times.
✓ Branch 1 taken 93 times.
128 if(compatrule_version < 22)
3559 93 set_qr(qr_BROKEN_KEEPOLD_FLAG,1);
3560
3561
2/2
✓ Branch 0 taken 35 times.
✓ Branch 1 taken 93 times.
128 if(compatrule_version < 23)
3562 93 set_qr(qr_OLD_HALF_MAGIC,1);
3563
3564
2/2
✓ Branch 0 taken 35 times.
✓ Branch 1 taken 93 times.
128 if(compatrule_version < 24)
3565 {
3566 93 set_qr(qr_WARPS_RESTART_DMAPSCRIPT,1);
3567 93 set_qr(qr_DMAP_0_CONTINUE_BUG,1);
3568 93 }
3569
3570
2/2
✓ Branch 0 taken 35 times.
✓ Branch 1 taken 93 times.
128 if(compatrule_version < 25)
3571 {
3572
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 93 times.
93 if (get_qr(qr_OLD_FAIRY_LIMIT)) set_qr(qr_OLD_FAIRY_LIMIT,0);
3573 93 else set_qr(qr_OLD_FAIRY_LIMIT,1);
3574 93 set_qr(qr_OLD_SCRIPTED_KNOCKBACK,1);
3575 93 }
3576
2/2
✓ Branch 0 taken 35 times.
✓ Branch 1 taken 93 times.
128 if(compatrule_version < 26)
3577 {
3578 93 set_qr(qr_OLD_KEESE_Z_AXIS,1);
3579 93 set_qr(qr_POLVIRE_NO_SHADOW,1);
3580 93 set_qr(qr_SUBSCR_OLD_SELECTOR,1);
3581 93 }
3582
2/2
✓ Branch 0 taken 35 times.
✓ Branch 1 taken 93 times.
128 if(compatrule_version < 27) //Noticed some junk data in the QR array...
3583 {
3584
2/2
✓ Branch 0 taken 27993 times.
✓ Branch 1 taken 93 times.
28086 for(auto q = qr_POLVIRE_NO_SHADOW+1; q < qr_PARSER_250DIVISION; ++q)
3585 27993 set_qr(q,0);
3586
2/2
✓ Branch 0 taken 10416 times.
✓ Branch 1 taken 93 times.
10509 for(auto q = qr_COMBODATA_INITD_MULT_TENK+1; q < QUESTRULES_NEW_SIZE*8; ++q)
3587 10416 set_qr(q,0);
3588 //This should nuke any remaining junk data... not sure if it affected anything previous. -Em
3589 93 }
3590
2/2
✓ Branch 0 taken 33 times.
✓ Branch 1 taken 95 times.
128 if(compatrule_version < 28)
3591 95 set_qr(qr_SUBSCR_BACKWARDS_ID_ORDER,1);
3592
2/2
✓ Branch 0 taken 33 times.
✓ Branch 1 taken 95 times.
128 if(compatrule_version < 29)
3593 95 set_qr(qr_OLD_LOCKBLOCK_COLLISION,1);
3594
2/2
✓ Branch 0 taken 33 times.
✓ Branch 1 taken 95 times.
128 if(compatrule_version < 30)
3595 {
3596 95 set_qr(qr_DECO_2_YOFFSET,1);
3597 95 set_qr(qr_SCREENSTATE_80s_BUG,1);
3598 95 }
3599
2/2
✓ Branch 0 taken 33 times.
✓ Branch 1 taken 95 times.
128 if(compatrule_version < 31)
3600 {
3601 95 set_qr(qr_GOHMA_UNDAMAGED_BUG,1);
3602 95 set_qr(qr_FFCPRELOAD_BUGGED_LOAD,1);
3603 95 }
3604
2/2
✓ Branch 0 taken 33 times.
✓ Branch 1 taken 95 times.
128 if(compatrule_version < 32)
3605 95 set_qr(qr_BROKEN_GETPIXEL_VALUE,1);
3606
2/2
✓ Branch 0 taken 33 times.
✓ Branch 1 taken 95 times.
128 if(compatrule_version < 33)
3607 95 set_qr(qr_NO_LIFT_SPRITE,1);
3608
2/2
✓ Branch 0 taken 33 times.
✓ Branch 1 taken 95 times.
128 if(compatrule_version < 34)
3609 {
3610 95 set_qr(qr_OLD_SIDEVIEW_LANDING_CODE,1);
3611 95 set_qr(qr_OLD_FFC_SPEED_CAP,1);
3612 95 set_qr(qr_OLD_FFC_FUNCTIONALITY,1);
3613 95 set_qr(qr_OLD_WIZZROBE_SUBMERGING,1);
3614 95 }
3615
2/2
✓ Branch 0 taken 32 times.
✓ Branch 1 taken 96 times.
128 if(compatrule_version < 35)
3616 {
3617 96 set_qr(qr_ZS_NO_NEG_ARRAY,1);
3618 96 set_qr(qr_BROKEN_INPUT_DOWN_STATE,1);
3619 96 }
3620
2/2
✓ Branch 0 taken 32 times.
✓ Branch 1 taken 96 times.
128 if(compatrule_version < 36)
3621 96 set_qr(qr_OLD_SHALLOW_SFX,1);
3622
2/2
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 98 times.
128 if(compatrule_version < 37)
3623 98 set_qr(qr_SPARKLES_INHERIT_PROPERTIES,1);
3624
2/2
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 98 times.
128 if(compatrule_version < 38)
3625 98 set_qr(qr_BUGGED_LAYERED_FLAGS,1);
3626
2/2
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 98 times.
128 if(compatrule_version < 39)
3627 98 set_qr(qr_HARDCODED_FFC_BUSH_DROPS,1);
3628
2/2
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 98 times.
128 if(compatrule_version < 40)
3629 98 set_qr(qr_MOVINGBLOCK_FAKE_SOLID,1);
3630
2/2
✓ Branch 0 taken 29 times.
✓ Branch 1 taken 99 times.
128 if(compatrule_version < 41)
3631 99 set_qr(qr_BROKENHITBY,1);
3632
2/2
✓ Branch 0 taken 29 times.
✓ Branch 1 taken 99 times.
128 if(compatrule_version < 42)
3633 99 set_qr(qr_BROKEN_MOVING_BOMBS,1);
3634
2/2
✓ Branch 0 taken 29 times.
✓ Branch 1 taken 99 times.
128 if(compatrule_version < 43)
3635 99 set_qr(qr_OLD_BOMB_HITBOXES,1);
3636
2/2
✓ Branch 0 taken 29 times.
✓ Branch 1 taken 99 times.
128 if(compatrule_version < 44)
3637 99 set_qr(qr_SCROLLWARP_NO_RESET_FRAME,1);
3638
2/2
✓ Branch 0 taken 29 times.
✓ Branch 1 taken 99 times.
128 if(compatrule_version < 45)
3639 99 set_qr(qr_ENEMIES_DONT_SCRIPT_FIRST_FRAME,1);
3640
2/2
✓ Branch 0 taken 29 times.
✓ Branch 1 taken 99 times.
128 if(compatrule_version < 46)
3641 99 set_qr(qr_BROKEN_RAFT_SCROLL,1);
3642
2/2
✓ Branch 0 taken 26 times.
✓ Branch 1 taken 102 times.
128 if(compatrule_version < 47)
3643 {
3644 102 set_qr(qr_SENSITIVE_SOLID_DAMAGE,1);
3645 102 set_qr(qr_OLD_CONVEYOR_COLLISION,1);
3646 102 }
3647
2/2
✓ Branch 0 taken 26 times.
✓ Branch 1 taken 102 times.
128 if(compatrule_version < 48)
3648 102 set_qr(qr_OLD_GUY_HANDLING,1);
3649
2/2
✓ Branch 0 taken 26 times.
✓ Branch 1 taken 102 times.
128 if(compatrule_version < 49)
3650 102 set_qr(qr_FAIRY_FLAG_COMPAT,1);
3651
2/2
✓ Branch 0 taken 26 times.
✓ Branch 1 taken 102 times.
128 if(compatrule_version < 50)
3652 102 set_qr(qr_OLD_LENS_LAYEREFFECT,1);
3653
2/2
✓ Branch 0 taken 26 times.
✓ Branch 1 taken 102 times.
128 if(compatrule_version < 51)
3654 102 set_qr(qr_PUSHBLOCK_SPRITE_LAYER,1);
3655
2/2
✓ Branch 0 taken 26 times.
✓ Branch 1 taken 102 times.
128 if (compatrule_version < 52)
3656 102 set_qr(qr_OLD_SCRIPT_VOLUME, 1);
3657
2/2
✓ Branch 0 taken 26 times.
✓ Branch 1 taken 102 times.
128 if(compatrule_version < 53)
3658 {
3659 102 set_qr(qr_OLD_SUBSCR,1);
3660 102 set_qr(qr_ITM_0_INVIS_ON_BTNS,1);
3661 102 set_qr(qr_OLD_GAUGE_TILE_LAYOUT,1);
3662 102 }
3663
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 120 times.
128 if(compatrule_version < 54)
3664 120 set_qr(qr_WALKTHROUGHWALL_NO_DOORSTATE,1);
3665
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 120 times.
128 if(compatrule_version < 55)
3666 120 set_qr(qr_SPOTLIGHT_IGNR_SOLIDOBJ,1);
3667
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 120 times.
128 if(compatrule_version < 56)
3668 120 set_qr(qr_BROKEN_LIGHTBEAM_HITBOX,1);
3669
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 120 times.
128 if(compatrule_version < 57)
3670 120 set_qr(qr_BROKEN_SWORD_SPIN_TRIGGERS,1);
3671
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 120 times.
128 if(compatrule_version < 58)
3672 120 set_qr(qr_OLD_DMAP_INTRO_STRINGS,1);
3673
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 120 times.
128 if(compatrule_version < 59)
3674 120 set_qr(qr_SCRIPT_CONTHP_IS_HEARTS,1);
3675
3676 128 set_qr(qr_ANIMATECUSTOMWEAPONS,0);
3677
2/2
✓ Branch 0 taken 35 times.
✓ Branch 1 taken 93 times.
128 if (s_version < 16)
3678 93 set_qr(qr_BROKEN_HORIZONTAL_WEAPON_ANIM,1);
3679
3680 128 memcpy(Header, &tempheader, sizeof(tempheader));
3681
3682 128 return 0;
3683 128 }
3684
3685 1076245 void init_msgstr(MsgStr *str)
3686 {
3687 1076245 str->s = "";
3688 1076245 str->s.shrink_to_fit();
3689 1076245 str->nextstring=0;
3690 1076245 str->tile=0;
3691 1076245 str->cset=0;
3692 1076245 str->trans=false;
3693 1076245 str->font=font_zfont;
3694 1076245 str->y=32;
3695 1076245 str->sfx=18;
3696 1076245 str->listpos=0;
3697 1076245 str->x=24;
3698 1076245 str->w=get_qr(qr_STRING_FRAME_OLD_WIDTH_HEIGHT)!=0 ? 24*8 : 26*8;
3699 1076245 str->h=get_qr(qr_STRING_FRAME_OLD_WIDTH_HEIGHT)!=0 ? 3*8 : 5*8;
3700 1076245 str->hspace=0;
3701 1076245 str->vspace=0;
3702 1076245 str->stringflags=0;
3703 1076245 str->margins[up] = 8;
3704 1076245 str->margins[down] = 0;
3705 1076245 str->margins[left] = 8;
3706 1076245 str->margins[right] = 0;
3707 1076245 str->portrait_tile = 0;
3708 1076245 str->portrait_cset = 0;
3709 1076245 str->portrait_x = 0;
3710 1076245 str->portrait_y = 0;
3711 1076245 str->portrait_tw = 1;
3712 1076245 str->portrait_th = 1;
3713 1076245 str->shadow_type = 0;
3714 1076245 str->shadow_color = 0;
3715 1076245 str->drawlayer = 6;
3716 1076245 }
3717
3718 128 void init_msgstrings(int32_t start, int32_t end)
3719 {
3720
2/4
✓ Branch 0 taken 128 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 128 times.
128 if(end <= start || end-start > msg_strings_size)
3721 return;
3722
3723
2/2
✓ Branch 0 taken 1048576 times.
✓ Branch 1 taken 128 times.
1048704 for(int32_t i=start; i<end; i++)
3724 {
3725 1048576 init_msgstr(&MsgStrings[i]);
3726 1048576 MsgStrings[i].listpos=i;
3727 1048576 }
3728
3729
1/2
✓ Branch 0 taken 128 times.
✗ Branch 1 not taken.
128 if(start==0)
3730 {
3731 128 MsgStrings[0].s = "(None)";
3732 128 MsgStrings[0].listpos = 0;
3733 128 }
3734 128 }
3735
3736 128 int32_t readstrings(PACKFILE *f, zquestheader *Header)
3737 {
3738
2/2
✓ Branch 0 taken 124 times.
✓ Branch 1 taken 4 times.
128 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_strings);
3739
3740 128 MsgStr tempMsgString;
3741
1/2
✓ Branch 0 taken 128 times.
✗ Branch 1 not taken.
128 init_msgstr(&tempMsgString);
3742
3743 128 word temp_msg_count=0;
3744 word temp_expansion[16];
3745 128 memset(temp_expansion, 0, 16*sizeof(word));
3746 128 char buf[8193] = {0};
3747
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 124 times.
128 if(Header->zelda_version < 0x193)
3748 {
3749 byte tempbyte;
3750 4 int32_t strings_to_read=0;
3751
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if (!should_skip)
3752
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 set_qr(qr_OLD_STRING_EDITOR_MARGINS,true);
3753
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
4 if((Header->zelda_version < 0x192)||
3754 ((Header->zelda_version == 0x192)&&(Header->build<31)))
3755 {
3756 4 strings_to_read=128;
3757 4 temp_msg_count=Header->old_str_count;
3758
3759 // Some sort of string count corruption seems to be common in old quests
3760
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(temp_msg_count>128)
3761 {
3762 temp_msg_count=128;
3763 }
3764 4 }
3765 else if((Header->zelda_version == 0x192)&&(Header->build<140))
3766 {
3767 strings_to_read=255;
3768 temp_msg_count=Header->old_str_count;
3769 }
3770 else
3771 {
3772 if(!p_igetw(&temp_msg_count,f))
3773 {
3774 return qe_invalid;
3775 }
3776
3777 strings_to_read=temp_msg_count;
3778
3779 if (!should_skip && temp_msg_count >= msg_strings_size)
3780 {
3781 Z_message("Reallocating string buffer...\n");
3782
3783 // if((MsgStrings=(MsgStr*)_al_sane_realloc(MsgStrings,sizeof(MsgStr)*MAXMSGS))==NULL)
3784 // return qe_nomem;
3785
3786 //memset(MsgStrings, 0, sizeof(MsgStr)*MAXMSGS);
3787 delete[] MsgStrings;
3788 MsgStrings = new MsgStr[MAXMSGS];
3789 msg_strings_size = MAXMSGS;
3790 for(auto q = 0; q < msg_strings_size; ++q)
3791 {
3792 MsgStrings[q].clear();
3793 }
3794 }
3795 }
3796
3797 //reset the message strings
3798
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if (!should_skip)
3799
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 init_msgstrings(0,msg_strings_size);
3800
3801
2/2
✓ Branch 0 taken 512 times.
✓ Branch 1 taken 4 times.
516 for(int32_t x=0; x<strings_to_read; x++)
3802 {
3803
1/2
✓ Branch 0 taken 512 times.
✗ Branch 1 not taken.
512 init_msgstr(&tempMsgString);
3804 512 tempMsgString.listpos = x;
3805
3806
2/4
✓ Branch 0 taken 512 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 512 times.
✗ Branch 3 not taken.
512 if(!pfread(buf,73,f))
3807 {
3808 return qe_invalid;
3809 }
3810
3811 512 buf[74] = '\0';
3812
1/2
✓ Branch 0 taken 512 times.
✗ Branch 1 not taken.
512 tempMsgString.s = buf;
3813
3814
2/4
✓ Branch 0 taken 512 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 512 times.
✗ Branch 3 not taken.
512 if(!p_getc(&tempbyte,f))
3815 {
3816 return qe_invalid;
3817 }
3818
3819
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 512 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
512 if((Header->zelda_version < 0x192)||
3820 ((Header->zelda_version == 0x192)&&(Header->build<148)))
3821 {
3822
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 512 times.
512 tempMsgString.nextstring=tempbyte?x+1:0;
3823
3824
2/4
✓ Branch 0 taken 512 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 512 times.
✗ Branch 3 not taken.
512 if(!p_getc(&tempbyte,f))
3825 {
3826 return qe_invalid;
3827 }
3828
3829
2/4
✓ Branch 0 taken 512 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 512 times.
✗ Branch 3 not taken.
512 if(!p_getc(&tempbyte,f))
3830 {
3831 return qe_invalid;
3832 }
3833 512 }
3834 else
3835 {
3836 if(!p_igetw(&tempMsgString.nextstring,f))
3837 {
3838 return qe_invalid;
3839 }
3840
3841 if(!pfread(temp_expansion,32,f))
3842 {
3843 return qe_invalid;
3844 }
3845 }
3846
3847
1/2
✓ Branch 0 taken 512 times.
✗ Branch 1 not taken.
512 if (!should_skip)
3848
1/2
✓ Branch 0 taken 512 times.
✗ Branch 1 not taken.
512 MsgStrings[x] = tempMsgString;
3849 512 }
3850 4 }
3851 else
3852 {
3853 int32_t dummy_int;
3854 word s_version;
3855 word s_cversion;
3856
3857 //section version info
3858
2/4
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 124 times.
✗ Branch 3 not taken.
124 if(!p_igetw(&s_version,f))
3859 {
3860 return qe_invalid;
3861 }
3862
3863 124 FFCore.quest_format[vStrings] = s_version;
3864
3865
2/4
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 124 times.
✗ Branch 3 not taken.
124 if(!p_igetw(&s_cversion,f))
3866 {
3867 return qe_invalid;
3868 }
3869
3870 //al_trace("Strings version %d\n", s_version);
3871 //section size
3872
2/4
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 124 times.
✗ Branch 3 not taken.
124 if(!p_igetl(&dummy_int,f))
3873 {
3874 return qe_invalid;
3875 }
3876
3877 //finally... section data
3878
2/4
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 124 times.
✗ Branch 3 not taken.
124 if(!p_igetw(&temp_msg_count,f))
3879 {
3880 return qe_invalid;
3881 }
3882
3883
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 124 times.
124 if(temp_msg_count >= msg_strings_size)
3884 {
3885 Z_message("Reallocating string buffer...\n");
3886
3887 // if((MsgStrings=(MsgStr*)_al_sane_realloc(MsgStrings,sizeof(MsgStr)*MAXMSGS))==NULL)
3888 // return qe_nomem;
3889 delete[] MsgStrings;
3890 MsgStrings = new MsgStr[MAXMSGS];
3891 msg_strings_size = MAXMSGS;
3892 for(auto q = 0; q < msg_strings_size; ++q)
3893 {
3894 MsgStrings[q].clear();
3895 }
3896 //memset(MsgStrings, 0, sizeof(MsgStr)*MAXMSGS);
3897 }
3898
3899 //reset the message strings
3900
2/2
✓ Branch 0 taken 89 times.
✓ Branch 1 taken 35 times.
124 if(s_version < 7)
3901
1/2
✓ Branch 0 taken 89 times.
✗ Branch 1 not taken.
89 set_qr(qr_OLD_STRING_EDITOR_MARGINS,true);
3902
1/2
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
124 init_msgstrings(0,msg_strings_size);
3903
3904 124 int32_t string_length=(s_version<2)?73:145;
3905
3906
2/2
✓ Branch 0 taken 27029 times.
✓ Branch 1 taken 124 times.
27153 for(int32_t i=0; i<temp_msg_count; i++)
3907 {
3908
1/2
✓ Branch 0 taken 27029 times.
✗ Branch 1 not taken.
27029 init_msgstr(&tempMsgString);
3909 27029 tempMsgString.listpos = i;
3910
2/2
✓ Branch 0 taken 890 times.
✓ Branch 1 taken 26139 times.
27029 if(s_version > 8)
3911 {
3912
2/4
✓ Branch 0 taken 890 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 890 times.
✗ Branch 3 not taken.
890 if(!p_igetl(&string_length,f))
3913 {
3914 return qe_invalid;
3915 }
3916 890 }
3917
3918
2/4
✓ Branch 0 taken 27029 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 27029 times.
27029 if (string_length < 0 || string_length > 8193)
3919 {
3920 return qe_invalid;
3921 }
3922
3923
2/2
✓ Branch 0 taken 26891 times.
✓ Branch 1 taken 138 times.
27029 if (string_length > 0)
3924 {
3925
2/4
✓ Branch 0 taken 26891 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 26891 times.
✗ Branch 3 not taken.
26891 if (!pfread(buf, string_length, f))
3926 {
3927 return qe_invalid;
3928 }
3929 26891 }
3930 else
3931 {
3932 138 buf[0] = 0;
3933 }
3934
3935
2/4
✓ Branch 0 taken 27029 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 27029 times.
✗ Branch 3 not taken.
27029 if(!p_igetw(&tempMsgString.nextstring,f))
3936 {
3937 return qe_invalid;
3938 }
3939
3940
2/2
✓ Branch 0 taken 19101 times.
✓ Branch 1 taken 7928 times.
27029 if(s_version<2)
3941 {
3942 19101 buf[72] = '\0';
3943
1/2
✓ Branch 0 taken 19101 times.
✗ Branch 1 not taken.
19101 tempMsgString.s = buf;
3944 19101 }
3945 else
3946 {
3947 // June 2008: A bug corrupted the last 4 chars of a string.
3948 // Discard these.
3949
1/2
✓ Branch 0 taken 7928 times.
✗ Branch 1 not taken.
7928 if(s_version<3)
3950 {
3951 for(int32_t j=140; j<144; j++)
3952 {
3953 buf[j] = '\0';
3954 }
3955 }
3956
1/2
✓ Branch 0 taken 7928 times.
✗ Branch 1 not taken.
7928 if(string_length > 8192) string_length = 8192;
3957 7928 buf[string_length]='\0'; //Force-terminate
3958
1/2
✓ Branch 0 taken 7928 times.
✗ Branch 1 not taken.
7928 tempMsgString.s = buf;
3959
3960
2/2
✓ Branch 0 taken 890 times.
✓ Branch 1 taken 7038 times.
7928 if ( s_version >= 6 )
3961 {
3962
2/4
✓ Branch 0 taken 890 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 890 times.
✗ Branch 3 not taken.
890 if(!p_igetl(&tempMsgString.tile,f))
3963 {
3964 return qe_invalid;
3965 }
3966 890 }
3967 else
3968 {
3969
2/4
✓ Branch 0 taken 7038 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7038 times.
✗ Branch 3 not taken.
7038 if(!p_igetw(&tempMsgString.tile,f))
3970 {
3971 return qe_invalid;
3972 }
3973 }
3974
3975
2/4
✓ Branch 0 taken 7928 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7928 times.
✗ Branch 3 not taken.
7928 if(!p_getc(&tempMsgString.cset,f))
3976 {
3977 return qe_invalid;
3978 }
3979
3980 byte dummy_char;
3981
3982
2/4
✓ Branch 0 taken 7928 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7928 times.
✗ Branch 3 not taken.
7928 if(!p_getc(&dummy_char,f)) // trans is stored as a char...
3983 {
3984 return qe_invalid;
3985 }
3986
3987 7928 tempMsgString.trans=dummy_char!=0;
3988
3989
2/4
✓ Branch 0 taken 7928 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7928 times.
✗ Branch 3 not taken.
7928 if(!p_getc(&tempMsgString.font,f))
3990 {
3991 return qe_invalid;
3992 }
3993
3994
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7928 times.
7928 if(s_version < 5)
3995 {
3996 if(!p_getc(&tempMsgString.y,f))
3997 {
3998 return qe_invalid;
3999 }
4000 }
4001 else
4002 {
4003
2/4
✓ Branch 0 taken 7928 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7928 times.
✗ Branch 3 not taken.
7928 if(!p_igetw(&tempMsgString.x,f))
4004 {
4005 return qe_invalid;
4006 }
4007
4008
2/4
✓ Branch 0 taken 7928 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7928 times.
✗ Branch 3 not taken.
7928 if(!p_igetw(&tempMsgString.y,f))
4009 {
4010 return qe_invalid;
4011 }
4012
4013
2/4
✓ Branch 0 taken 7928 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7928 times.
✗ Branch 3 not taken.
7928 if(!p_igetw(&tempMsgString.w,f))
4014 {
4015 return qe_invalid;
4016 }
4017
4018
2/4
✓ Branch 0 taken 7928 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7928 times.
✗ Branch 3 not taken.
7928 if(!p_igetw(&tempMsgString.h,f))
4019 {
4020 return qe_invalid;
4021 }
4022
4023
2/4
✓ Branch 0 taken 7928 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7928 times.
✗ Branch 3 not taken.
7928 if(!p_getc(&tempMsgString.hspace,f))
4024 {
4025 return qe_invalid;
4026 }
4027
4028
2/4
✓ Branch 0 taken 7928 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7928 times.
✗ Branch 3 not taken.
7928 if(!p_getc(&tempMsgString.vspace,f))
4029 {
4030 return qe_invalid;
4031 }
4032
4033
2/4
✓ Branch 0 taken 7928 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7928 times.
✗ Branch 3 not taken.
7928 if(!p_getc(&tempMsgString.stringflags,f))
4034 {
4035 return qe_invalid;
4036 }
4037 }
4038
4039
2/2
✓ Branch 0 taken 7038 times.
✓ Branch 1 taken 890 times.
7928 if(s_version >= 7)
4040 {
4041
2/2
✓ Branch 0 taken 890 times.
✓ Branch 1 taken 3560 times.
4450 for(int32_t q = 0; q < 4; ++q)
4042 {
4043
2/4
✓ Branch 0 taken 3560 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3560 times.
✗ Branch 3 not taken.
3560 if(!p_getc(&tempMsgString.margins[q],f))
4044 {
4045 return qe_invalid;
4046 }
4047 3560 }
4048
4049
2/4
✓ Branch 0 taken 890 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 890 times.
✗ Branch 3 not taken.
890 if(!p_igetl(&tempMsgString.portrait_tile,f))
4050 {
4051 return qe_invalid;
4052 }
4053
4054
2/4
✓ Branch 0 taken 890 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 890 times.
✗ Branch 3 not taken.
890 if(!p_getc(&tempMsgString.portrait_cset,f))
4055 {
4056 return qe_invalid;
4057 }
4058
4059
2/4
✓ Branch 0 taken 890 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 890 times.
✗ Branch 3 not taken.
890 if(!p_getc(&tempMsgString.portrait_x,f))
4060 {
4061 return qe_invalid;
4062 }
4063
4064
2/4
✓ Branch 0 taken 890 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 890 times.
✗ Branch 3 not taken.
890 if(!p_getc(&tempMsgString.portrait_y,f))
4065 {
4066 return qe_invalid;
4067 }
4068
4069
2/4
✓ Branch 0 taken 890 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 890 times.
✗ Branch 3 not taken.
890 if(!p_getc(&tempMsgString.portrait_tw,f))
4070 {
4071 return qe_invalid;
4072 }
4073
4074
2/4
✓ Branch 0 taken 890 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 890 times.
✗ Branch 3 not taken.
890 if(!p_getc(&tempMsgString.portrait_th,f))
4075 {
4076 return qe_invalid;
4077 }
4078 890 }
4079
4080
2/2
✓ Branch 0 taken 890 times.
✓ Branch 1 taken 7038 times.
7928 if(s_version >= 8)
4081 {
4082
2/4
✓ Branch 0 taken 890 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 890 times.
✗ Branch 3 not taken.
890 if(!p_getc(&tempMsgString.shadow_type,f))
4083 {
4084 return qe_invalid;
4085 }
4086
4087
2/4
✓ Branch 0 taken 890 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 890 times.
✗ Branch 3 not taken.
890 if(!p_getc(&tempMsgString.shadow_color,f))
4088 {
4089 return qe_invalid;
4090 }
4091 890 }
4092
4093
2/2
✓ Branch 0 taken 773 times.
✓ Branch 1 taken 7155 times.
7928 if(s_version >= 10)
4094 {
4095
2/4
✓ Branch 0 taken 773 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 773 times.
✗ Branch 3 not taken.
773 if(!p_getc(&tempMsgString.drawlayer,f))
4096 {
4097 return qe_invalid;
4098 }
4099 773 }
4100
4101
2/4
✓ Branch 0 taken 7928 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7928 times.
✗ Branch 3 not taken.
7928 if(!p_getc(&tempMsgString.sfx,f))
4102 {
4103 return qe_invalid;
4104 }
4105
4106
1/2
✓ Branch 0 taken 7928 times.
✗ Branch 1 not taken.
7928 if(s_version>3)
4107 {
4108
2/4
✓ Branch 0 taken 7928 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7928 times.
✗ Branch 3 not taken.
7928 if(!p_igetw(&tempMsgString.listpos,f))
4109 {
4110 return qe_invalid;
4111 }
4112 7928 }
4113 }
4114
4115
1/2
✓ Branch 0 taken 27029 times.
✗ Branch 1 not taken.
27029 MsgStrings[i].copyAll(tempMsgString);
4116 27029 }
4117 }
4118
4119
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 128 times.
128 if (!should_skip)
4120 128 msg_count=temp_msg_count;
4121
4122 128 return 0;
4123 128 }
4124
4125 128 int32_t readdoorcombosets(PACKFILE *f, zquestheader *Header)
4126 {
4127
2/2
✓ Branch 0 taken 124 times.
✓ Branch 1 taken 4 times.
128 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_doors);
4128
4129
2/4
✓ Branch 0 taken 124 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
128 if((Header->zelda_version < 0x192)||
4130
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 124 times.
124 ((Header->zelda_version == 0x192)&&(Header->build<158)))
4131 {
4132 4 return 0;
4133 }
4134
4135 124 word temp_door_combo_set_count=0;
4136 DoorComboSet tempDoorComboSet;
4137 word dummy_word;
4138 int32_t dummy_long;
4139 byte padding;
4140 124 int32_t s_version = 0;
4141
4142
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 124 times.
124 if (!should_skip)
4143
2/2
✓ Branch 0 taken 31744 times.
✓ Branch 1 taken 124 times.
31868 for(int32_t i=0; i<MAXDOORCOMBOSETS; i++)
4144 {
4145 31744 memset(DoorComboSets+i, 0, sizeof(DoorComboSet));
4146 31868 }
4147
4148
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 124 times.
124 if(Header->zelda_version > 0x192)
4149 {
4150 //section version info
4151
1/2
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
124 if(!p_igetw(&s_version,f))
4152 {
4153 return qe_invalid;
4154 }
4155
4156 124 FFCore.quest_format[vDoors] = s_version;
4157
4158 //al_trace("Door combo sets version %d\n", dummy_word);
4159
1/2
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
124 if(!p_igetw(&dummy_word,f))
4160 {
4161 return qe_invalid;
4162 }
4163
4164 //section size
4165
1/2
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
124 if(!p_igetl(&dummy_long,f))
4166 {
4167 return qe_invalid;
4168 }
4169 124 }
4170
4171 //finally... section data
4172
1/2
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
124 if(!p_igetw(&temp_door_combo_set_count,f))
4173 {
4174 return qe_invalid;
4175 }
4176
4177
2/4
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 124 times.
124 if (!(temp_door_combo_set_count >= 0 && temp_door_combo_set_count <= MAXDOORCOMBOSETS))
4178 {
4179 return qe_invalid;
4180 }
4181
4182
2/2
✓ Branch 0 taken 994 times.
✓ Branch 1 taken 124 times.
1118 for(int32_t i=0; i<temp_door_combo_set_count; i++)
4183 {
4184 994 memset(&tempDoorComboSet, 0, sizeof(DoorComboSet));
4185
4186 //name
4187
1/2
✓ Branch 0 taken 994 times.
✗ Branch 1 not taken.
994 if(!pfread(&tempDoorComboSet.name,sizeof(tempDoorComboSet.name),f))
4188 {
4189 return qe_invalid;
4190 }
4191
4192
1/2
✓ Branch 0 taken 994 times.
✗ Branch 1 not taken.
994 if(Header->zelda_version < 0x193)
4193 {
4194 if(!p_getc(&padding,f))
4195 {
4196 return qe_invalid;
4197 }
4198 }
4199
4200 //up door
4201
2/2
✓ Branch 0 taken 8946 times.
✓ Branch 1 taken 994 times.
9940 for(int32_t j=0; j<9; j++)
4202 {
4203
2/2
✓ Branch 0 taken 35784 times.
✓ Branch 1 taken 8946 times.
44730 for(int32_t k=0; k<4; k++)
4204 {
4205
1/2
✓ Branch 0 taken 35784 times.
✗ Branch 1 not taken.
35784 if(!p_igetw(&tempDoorComboSet.doorcombo_u[j][k],f))
4206 {
4207 return qe_invalid;
4208 }
4209 35784 }
4210 8946 }
4211
4212
2/2
✓ Branch 0 taken 8946 times.
✓ Branch 1 taken 994 times.
9940 for(int32_t j=0; j<9; j++)
4213 {
4214
2/2
✓ Branch 0 taken 35784 times.
✓ Branch 1 taken 8946 times.
44730 for(int32_t k=0; k<4; k++)
4215 {
4216
1/2
✓ Branch 0 taken 35784 times.
✗ Branch 1 not taken.
35784 if(!p_getc(&tempDoorComboSet.doorcset_u[j][k],f))
4217 {
4218 return qe_invalid;
4219 }
4220 35784 }
4221 8946 }
4222
4223 //down door
4224
2/2
✓ Branch 0 taken 8946 times.
✓ Branch 1 taken 994 times.
9940 for(int32_t j=0; j<9; j++)
4225 {
4226
2/2
✓ Branch 0 taken 35784 times.
✓ Branch 1 taken 8946 times.
44730 for(int32_t k=0; k<4; k++)
4227 {
4228
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 35784 times.
35784 if(!p_igetw(&tempDoorComboSet.doorcombo_d[j][k],f))
4229 {
4230 return qe_invalid;
4231 }
4232 35784 }
4233 8946 }
4234
4235
2/2
✓ Branch 0 taken 8946 times.
✓ Branch 1 taken 994 times.
9940 for(int32_t j=0; j<9; j++)
4236 {
4237
2/2
✓ Branch 0 taken 35784 times.
✓ Branch 1 taken 8946 times.
44730 for(int32_t k=0; k<4; k++)
4238 {
4239
1/2
✓ Branch 0 taken 35784 times.
✗ Branch 1 not taken.
35784 if(!p_getc(&tempDoorComboSet.doorcset_d[j][k],f))
4240 {
4241 return qe_invalid;
4242 }
4243 35784 }
4244 8946 }
4245
4246 //left door
4247
2/2
✓ Branch 0 taken 8946 times.
✓ Branch 1 taken 994 times.
9940 for(int32_t j=0; j<9; j++)
4248 {
4249
2/2
✓ Branch 0 taken 53676 times.
✓ Branch 1 taken 8946 times.
62622 for(int32_t k=0; k<6; k++)
4250 {
4251
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 53676 times.
53676 if(!p_igetw(&tempDoorComboSet.doorcombo_l[j][k],f))
4252 {
4253 return qe_invalid;
4254 }
4255 53676 }
4256 8946 }
4257
4258
2/2
✓ Branch 0 taken 8946 times.
✓ Branch 1 taken 994 times.
9940 for(int32_t j=0; j<9; j++)
4259 {
4260
2/2
✓ Branch 0 taken 53676 times.
✓ Branch 1 taken 8946 times.
62622 for(int32_t k=0; k<6; k++)
4261 {
4262
1/2
✓ Branch 0 taken 53676 times.
✗ Branch 1 not taken.
53676 if(!p_getc(&tempDoorComboSet.doorcset_l[j][k],f))
4263 {
4264 return qe_invalid;
4265 }
4266 53676 }
4267 8946 }
4268
4269 //right door
4270
2/2
✓ Branch 0 taken 8946 times.
✓ Branch 1 taken 994 times.
9940 for(int32_t j=0; j<9; j++)
4271 {
4272
2/2
✓ Branch 0 taken 53676 times.
✓ Branch 1 taken 8946 times.
62622 for(int32_t k=0; k<6; k++)
4273 {
4274
1/2
✓ Branch 0 taken 53676 times.
✗ Branch 1 not taken.
53676 if(!p_igetw(&tempDoorComboSet.doorcombo_r[j][k],f))
4275 {
4276 return qe_invalid;
4277 }
4278 53676 }
4279 8946 }
4280
4281
2/2
✓ Branch 0 taken 8946 times.
✓ Branch 1 taken 994 times.
9940 for(int32_t j=0; j<9; j++)
4282 {
4283
2/2
✓ Branch 0 taken 53676 times.
✓ Branch 1 taken 8946 times.
62622 for(int32_t k=0; k<6; k++)
4284 {
4285
1/2
✓ Branch 0 taken 53676 times.
✗ Branch 1 not taken.
53676 if(!p_getc(&tempDoorComboSet.doorcset_r[j][k],f))
4286 {
4287 return qe_invalid;
4288 }
4289 53676 }
4290 8946 }
4291
4292 //up bomb rubble
4293
2/2
✓ Branch 0 taken 1988 times.
✓ Branch 1 taken 994 times.
2982 for(int32_t j=0; j<2; j++)
4294 {
4295
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1988 times.
1988 if(!p_igetw(&tempDoorComboSet.bombdoorcombo_u[j],f))
4296 {
4297 return qe_invalid;
4298 }
4299 1988 }
4300
4301
2/2
✓ Branch 0 taken 1988 times.
✓ Branch 1 taken 994 times.
2982 for(int32_t j=0; j<2; j++)
4302 {
4303
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1988 times.
1988 if(!p_getc(&tempDoorComboSet.bombdoorcset_u[j],f))
4304 {
4305 return qe_invalid;
4306 }
4307 1988 }
4308
4309 //down bomb rubble
4310
2/2
✓ Branch 0 taken 1988 times.
✓ Branch 1 taken 994 times.
2982 for(int32_t j=0; j<2; j++)
4311 {
4312
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1988 times.
1988 if(!p_igetw(&tempDoorComboSet.bombdoorcombo_d[j],f))
4313 {
4314 return qe_invalid;
4315 }
4316 1988 }
4317
4318
2/2
✓ Branch 0 taken 1988 times.
✓ Branch 1 taken 994 times.
2982 for(int32_t j=0; j<2; j++)
4319 {
4320
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1988 times.
1988 if(!p_getc(&tempDoorComboSet.bombdoorcset_d[j],f))
4321 {
4322 return qe_invalid;
4323 }
4324 1988 }
4325
4326 //left bomb rubble
4327
2/2
✓ Branch 0 taken 2982 times.
✓ Branch 1 taken 994 times.
3976 for(int32_t j=0; j<3; j++)
4328 {
4329
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2982 times.
2982 if(!p_igetw(&tempDoorComboSet.bombdoorcombo_l[j],f))
4330 {
4331 return qe_invalid;
4332 }
4333 2982 }
4334
4335
2/2
✓ Branch 0 taken 2982 times.
✓ Branch 1 taken 994 times.
3976 for(int32_t j=0; j<3; j++)
4336 {
4337
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2982 times.
2982 if(!p_getc(&tempDoorComboSet.bombdoorcset_l[j],f))
4338 {
4339 return qe_invalid;
4340 }
4341 2982 }
4342
4343
1/2
✓ Branch 0 taken 994 times.
✗ Branch 1 not taken.
994 if(Header->zelda_version < 0x193)
4344 {
4345 if(!p_getc(&padding,f))
4346 {
4347 return qe_invalid;
4348 }
4349
4350 }
4351
4352 //right bomb rubble
4353
2/2
✓ Branch 0 taken 2982 times.
✓ Branch 1 taken 994 times.
3976 for(int32_t j=0; j<3; j++)
4354 {
4355
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2982 times.
2982 if(!p_igetw(&tempDoorComboSet.bombdoorcombo_r[j],f))
4356 {
4357 return qe_invalid;
4358 }
4359 2982 }
4360
4361
2/2
✓ Branch 0 taken 2982 times.
✓ Branch 1 taken 994 times.
3976 for(int32_t j=0; j<3; j++)
4362 {
4363
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2982 times.
2982 if(!p_getc(&tempDoorComboSet.bombdoorcset_r[j],f))
4364 {
4365 return qe_invalid;
4366 }
4367 2982 }
4368
4369
1/2
✓ Branch 0 taken 994 times.
✗ Branch 1 not taken.
994 if(Header->zelda_version < 0x193)
4370 {
4371 if(!p_getc(&padding,f))
4372 {
4373 return qe_invalid;
4374 }
4375 }
4376
4377 //walkthrough stuff
4378
2/2
✓ Branch 0 taken 3976 times.
✓ Branch 1 taken 994 times.
4970 for(int32_t j=0; j<4; j++)
4379 {
4380
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3976 times.
3976 if(!p_igetw(&tempDoorComboSet.walkthroughcombo[j],f))
4381 {
4382 return qe_invalid;
4383 }
4384 3976 }
4385
4386
2/2
✓ Branch 0 taken 3976 times.
✓ Branch 1 taken 994 times.
4970 for(int32_t j=0; j<4; j++)
4387 {
4388
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3976 times.
3976 if(!p_getc(&tempDoorComboSet.walkthroughcset[j],f))
4389 {
4390 return qe_invalid;
4391 }
4392 3976 }
4393
4394 //flags
4395
2/2
✓ Branch 0 taken 1988 times.
✓ Branch 1 taken 994 times.
2982 for(int32_t j=0; j<2; j++)
4396 {
4397
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1988 times.
1988 if(!p_getc(&tempDoorComboSet.flags[j],f))
4398 {
4399 return qe_invalid;
4400 }
4401 1988 }
4402
4403
1/2
✓ Branch 0 taken 994 times.
✗ Branch 1 not taken.
994 if(Header->zelda_version < 0x193)
4404 {
4405 if(!pfread(&tempDoorComboSet.expansion,sizeof(tempDoorComboSet.expansion),f))
4406 {
4407 return qe_invalid;
4408 }
4409 }
4410
4411
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 994 times.
994 if (!should_skip)
4412 994 memcpy(&DoorComboSets[i], &tempDoorComboSet, sizeof(tempDoorComboSet));
4413 994 }
4414
4415
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 124 times.
124 if (!should_skip)
4416 124 door_combo_set_count=temp_door_combo_set_count;
4417
4418 124 return 0;
4419 128 }
4420
4421 int32_t count_dmaps()
4422 {
4423 int32_t i=MAXDMAPS-1;
4424 bool found=false;
4425
4426 while(i>=0 && !found)
4427 {
4428 if((DMaps[i].map!=0)||(DMaps[i].level!=0)||(DMaps[i].xoff!=0)||
4429 (DMaps[i].compass!=0)||(DMaps[i].color!=0)||(DMaps[i].midi!=0)||
4430 (DMaps[i].cont!=0)||(DMaps[i].type!=0))
4431 found=true;
4432
4433 for(int32_t j=0; j<8; j++)
4434 {
4435 if(DMaps[i].grid[j]!=0)
4436
4437 found=true;
4438 }
4439
4440 if((DMaps[i].name[0]!=0)||(DMaps[i].title[0]!=0)||
4441 (DMaps[i].intro[0]!=0)||(DMaps[i].tmusic[0]!=0))
4442 found=true;
4443
4444 if((DMaps[i].minimap_1_tile!=0)||(DMaps[i].minimap_2_tile!=0)||
4445 (DMaps[i].largemap_1_tile!=0)||(DMaps[i].largemap_2_tile!=0)||
4446 (DMaps[i].minimap_1_cset!=0)||(DMaps[i].minimap_2_cset!=0)||
4447 (DMaps[i].largemap_1_cset!=0)||(DMaps[i].largemap_2_cset!=0))
4448 found=true;
4449
4450 if(!found)
4451 {
4452 i--;
4453 }
4454 }
4455
4456 return i+1;
4457 }
4458
4459
4460 int32_t count_shops(miscQdata *Misc)
4461 {
4462 int32_t i=NUM_SHOPS-1,j;
4463 bool found=false;
4464
4465 while(i>=0 && !found)
4466 {
4467 j=2;
4468
4469 while(j>=0 && !found)
4470 {
4471 if((Misc->shop[i].hasitem[j]!=0)||(Misc->shop[i].price[j]!=0))
4472 {
4473 found=true;
4474 }
4475 else
4476 {
4477 j--;
4478 }
4479 }
4480
4481 if(Misc->shop[i].name[0]!=0)
4482 {
4483 found=true;
4484 }
4485
4486 if(!found)
4487 {
4488 i--;
4489 }
4490 }
4491
4492 return i+1;
4493 }
4494
4495 int32_t count_infos(miscQdata *Misc)
4496 {
4497 int32_t i=255,j;
4498 bool found=false;
4499
4500 while(i>=0 && !found)
4501 {
4502 j=2;
4503
4504 while(j>=0 && !found)
4505 {
4506 if((Misc->info[i].str[j]!=0)||(Misc->info[i].price[j]!=0))
4507 {
4508 found=true;
4509 }
4510 else
4511 {
4512 j--;
4513 }
4514 }
4515
4516 if(Misc->info[i].name[0]!=0)
4517 {
4518 found=true;
4519 }
4520
4521 if(!found)
4522 {
4523 i--;
4524 }
4525 }
4526
4527 return i+1;
4528 }
4529
4530 int32_t count_warprings(miscQdata *Misc)
4531 {
4532 int32_t i=15,j;
4533 bool found=false;
4534
4535 while(i>=0 && !found)
4536 {
4537 j=7;
4538
4539 while(j>=0 && !found)
4540 {
4541 if((Misc->warp[i].dmap[j]!=0)||(Misc->warp[i].scr[j]!=0))
4542 {
4543 found=true;
4544 }
4545 else
4546 {
4547 j--;
4548 }
4549 }
4550
4551 if(!found)
4552 {
4553 i--;
4554 }
4555 }
4556
4557 return i+1;
4558 }
4559
4560 int32_t count_palcycles(miscQdata *Misc)
4561 {
4562 int32_t i=255,j;
4563 bool found=false;
4564
4565 while(i>=0 && !found)
4566 {
4567 j=2;
4568
4569 while(j>=0 && !found)
4570 {
4571 if(Misc->cycles[i][j].count!=0)
4572 {
4573 found=true;
4574 }
4575 else
4576 {
4577 j--;
4578 }
4579 }
4580
4581 if(!found)
4582 {
4583 i--;
4584 }
4585 }
4586
4587 return i+1;
4588 }
4589
4590 264440 void clear_screen(mapscr *temp_scr)
4591 {
4592 264440 temp_scr->zero_memory();
4593 264440 }
4594
4595 128 int32_t readdmaps(PACKFILE *f, zquestheader *Header, word, word, word start_dmap, word max_dmaps)
4596 {
4597
2/2
✓ Branch 0 taken 124 times.
✓ Branch 1 taken 4 times.
128 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_dmaps);
4598
4599 128 word dmapstoread=0;
4600 128 dmap tempDMap;
4601
4602 int32_t dummy;
4603 128 word s_version=0, s_cversion=0;
4604 byte padding;
4605
4606 char legacy_title[22];
4607
4608
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 128 times.
128 if (!should_skip)
4609
2/2
✓ Branch 0 taken 65536 times.
✓ Branch 1 taken 128 times.
65664 for(int32_t i=0; i<max_dmaps; i++)
4610 {
4611
1/2
✓ Branch 0 taken 65536 times.
✗ Branch 1 not taken.
65536 DMaps[start_dmap + i].clear();
4612 65536 sprintf(legacy_title," ");
4613 65536 sprintf(DMaps[start_dmap+i].intro," ");
4614 65536 DMaps[start_dmap+i].type |= dmCAVE;
4615 65664 }
4616
4617
3/4
✓ Branch 0 taken 128 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 124 times.
✓ Branch 3 taken 4 times.
128 if(!Header || Header->zelda_version > 0x192)
4618 {
4619 //section version info
4620
2/4
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 124 times.
✗ Branch 3 not taken.
124 if(!p_igetw(&s_version,f))
4621 {
4622 return qe_invalid;
4623 }
4624
4625 124 FFCore.quest_format[vDMaps] = s_version;
4626
4627 //al_trace("DMaps version %d\n", s_version);
4628
4629
2/4
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 124 times.
✗ Branch 3 not taken.
124 if(!p_igetw(&s_cversion,f))
4630 {
4631 return qe_invalid;
4632 }
4633
4634 //section size
4635
2/4
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 124 times.
✗ Branch 3 not taken.
124 if(!p_igetl(&dummy,f))
4636 {
4637 return qe_invalid;
4638 }
4639
4640 //finally... section data
4641
2/4
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 124 times.
✗ Branch 3 not taken.
124 if(!p_igetw(&dmapstoread,f))
4642 {
4643 return qe_invalid;
4644 }
4645 124 }
4646 else
4647 {
4648
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
4 if((Header->zelda_version < 0x192)||
4649 ((Header->zelda_version == 0x192)&&(Header->build<5)))
4650 {
4651 4 dmapstoread=32;
4652 4 }
4653 else if(s_version <= 4)
4654 {
4655 dmapstoread=OLDMAXDMAPS;
4656 }
4657 else
4658 {
4659 dmapstoread=MAXDMAPS;
4660 }
4661 }
4662
4663
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 112 times.
128 dmapstoread=zc_min(dmapstoread, max_dmaps);
4664
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 112 times.
128 dmapstoread=zc_min(dmapstoread, MAXDMAPS-start_dmap);
4665
4666
2/2
✓ Branch 0 taken 60544 times.
✓ Branch 1 taken 128 times.
60672 for(int32_t i=start_dmap; i<dmapstoread+start_dmap; i++)
4667 {
4668
1/2
✓ Branch 0 taken 60544 times.
✗ Branch 1 not taken.
60544 tempDMap.clear();
4669 60544 sprintf(legacy_title," ");
4670 60544 sprintf(tempDMap.intro," ");
4671
4672
2/4
✓ Branch 0 taken 60544 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 60544 times.
✗ Branch 3 not taken.
60544 if(!p_getc(&tempDMap.map,f))
4673 {
4674 return qe_invalid;
4675 }
4676
4677
2/2
✓ Branch 0 taken 3200 times.
✓ Branch 1 taken 57344 times.
60544 if(s_version <= 4)
4678 {
4679 byte tempbyte;
4680
4681
2/4
✓ Branch 0 taken 3200 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3200 times.
✗ Branch 3 not taken.
3200 if(!p_getc(&tempbyte,f))
4682 {
4683 return qe_invalid;
4684 }
4685
4686 3200 tempDMap.level=(word)tempbyte;
4687 3200 }
4688 else
4689 {
4690
2/4
✓ Branch 0 taken 57344 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 57344 times.
✗ Branch 3 not taken.
57344 if(!p_igetw(&tempDMap.level,f))
4691 {
4692 return qe_invalid;
4693 }
4694 }
4695
4696
2/4
✓ Branch 0 taken 60544 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 60544 times.
✗ Branch 3 not taken.
60544 if(!p_getc(&tempDMap.xoff,f))
4697 {
4698 return qe_invalid;
4699 }
4700
4701
2/4
✓ Branch 0 taken 60544 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 60544 times.
✗ Branch 3 not taken.
60544 if(!p_getc(&tempDMap.compass,f))
4702 {
4703 return qe_invalid;
4704 }
4705
4706
2/2
✓ Branch 0 taken 57344 times.
✓ Branch 1 taken 3200 times.
60544 if(s_version > 8) // February 2009
4707 {
4708
2/4
✓ Branch 0 taken 57344 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 57344 times.
✗ Branch 3 not taken.
57344 if(!p_igetw(&tempDMap.color,f))
4709 {
4710 return qe_invalid;
4711 }
4712 57344 }
4713 else
4714 {
4715 byte tempbyte;
4716
4717
2/4
✓ Branch 0 taken 3200 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3200 times.
✗ Branch 3 not taken.
3200 if(!p_getc(&tempbyte,f))
4718 {
4719 return qe_invalid;
4720 }
4721
4722 3200 tempDMap.color = (word)tempbyte;
4723 }
4724
4725
2/4
✓ Branch 0 taken 60544 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 60544 times.
✗ Branch 3 not taken.
60544 if(!p_getc(&tempDMap.midi,f))
4726 {
4727 return qe_invalid;
4728 }
4729
4730
2/4
✓ Branch 0 taken 60544 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 60544 times.
✗ Branch 3 not taken.
60544 if(!p_getc(&tempDMap.cont,f))
4731 {
4732 return qe_invalid;
4733 }
4734
4735
2/4
✓ Branch 0 taken 60544 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 60544 times.
✗ Branch 3 not taken.
60544 if(!p_getc(&tempDMap.type,f))
4736 {
4737 return qe_invalid;
4738 }
4739
4740
4/4
✓ Branch 0 taken 828 times.
✓ Branch 1 taken 59716 times.
✓ Branch 2 taken 816 times.
✓ Branch 3 taken 12 times.
61372 if((tempDMap.type & dmfTYPE) == dmOVERW &&
4741
1/2
✓ Branch 0 taken 828 times.
✗ Branch 1 not taken.
828 (!Header || Header->zelda_version >= 0x210)) // Not sure exactly when this changed
4742 816 tempDMap.xoff = 0;
4743
4744
2/2
✓ Branch 0 taken 60544 times.
✓ Branch 1 taken 484352 times.
544896 for(int32_t j=0; j<8; j++)
4745 {
4746
2/4
✓ Branch 0 taken 484352 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 484352 times.
✗ Branch 3 not taken.
484352 if(!p_getc(&tempDMap.grid[j],f))
4747 {
4748 return qe_invalid;
4749 }
4750 484352 }
4751
4752
4/6
✓ Branch 0 taken 60544 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 60416 times.
✓ Branch 3 taken 128 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 60416 times.
60544 if(Header && ((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<41))))
4753 {
4754
3/4
✓ Branch 0 taken 38 times.
✓ Branch 1 taken 90 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 38 times.
128 if(tempDMap.level>0&&tempDMap.level<10)
4755 {
4756 38 sprintf(legacy_title,"LEVEL-%d ", tempDMap.level);
4757 38 }
4758
1/2
✓ Branch 0 taken 128 times.
✗ Branch 1 not taken.
128 tempDMap.title.assign(legacy_title);
4759
4760
3/4
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 124 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4 times.
128 if(i==0 && Header->zelda_version <= 0x190)
4761 {
4762 4 tempDMap.cont-=tempDMap.xoff;
4763 4 tempDMap.compass-=tempDMap.xoff;
4764 4 }
4765
4766 //forgotten -DD
4767
2/2
✓ Branch 0 taken 38 times.
✓ Branch 1 taken 90 times.
128 if(tempDMap.level==0)
4768 {
4769 90 tempDMap.flags=dmfCAVES|dmf3STAIR|dmfWHIRLWIND|dmfGUYCAVES;
4770 90 }
4771 128 }
4772 else
4773 {
4774
2/4
✓ Branch 0 taken 60416 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 60416 times.
✗ Branch 3 not taken.
60416 if(!p_getstr(tempDMap.name,sizeof(DMaps[0].name) - 1,f))
4775 {
4776 return qe_invalid;
4777 }
4778
4779
2/2
✓ Branch 0 taken 56320 times.
✓ Branch 1 taken 4096 times.
60416 if(s_version<20)
4780 {
4781
2/4
✓ Branch 0 taken 56320 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 56320 times.
✗ Branch 3 not taken.
56320 if (!p_getstr(legacy_title, sizeof(legacy_title) - 1, f))
4782 {
4783 return qe_invalid;
4784 }
4785
1/2
✓ Branch 0 taken 56320 times.
✗ Branch 1 not taken.
56320 tempDMap.title.assign(legacy_title);
4786 56320 }
4787 else
4788 {
4789 4096 std::string tmptitle;
4790
2/4
✓ Branch 0 taken 4096 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4096 times.
✗ Branch 3 not taken.
4096 if (!p_getwstr(&tmptitle, f))
4791 {
4792 return qe_invalid;
4793 }
4794
1/2
✓ Branch 0 taken 4096 times.
✗ Branch 1 not taken.
4096 tempDMap.title.reserve(tmptitle.size());
4795
1/2
✓ Branch 0 taken 4096 times.
✗ Branch 1 not taken.
4096 tempDMap.title = tmptitle;
4796
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4096 times.
4096 }
4797
4798
2/4
✓ Branch 0 taken 60416 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 60416 times.
✗ Branch 3 not taken.
60416 if(!p_getstr(tempDMap.intro,sizeof(DMaps[0].intro)-1,f))
4799 {
4800 return qe_invalid;
4801 }
4802
4803
3/8
✓ Branch 0 taken 60416 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 60416 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 60416 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
60416 if(Header && ((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<152))))
4804 {
4805 if ((tempDMap.type & dmfTYPE) == dmOVERW) tempDMap.flags = dmfCAVES | dmf3STAIR | dmfWHIRLWIND | dmfGUYCAVES;
4806 DMaps[i] = tempDMap;
4807
4808 continue;
4809 }
4810
4811
2/4
✓ Branch 0 taken 60416 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 60416 times.
60416 if(Header && (Header->zelda_version < 0x193))
4812 {
4813 if(!p_getc(&padding,f))
4814 {
4815 return qe_invalid;
4816 }
4817 }
4818
2/2
✓ Branch 0 taken 17920 times.
✓ Branch 1 taken 42496 times.
60416 if ( s_version >= 11 )
4819 {
4820
2/4
✓ Branch 0 taken 17920 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 17920 times.
✗ Branch 3 not taken.
17920 if(!p_igetl(&tempDMap.minimap_1_tile,f))
4821 {
4822 return qe_invalid;
4823 }
4824 17920 }
4825 else
4826 {
4827
2/4
✓ Branch 0 taken 42496 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 42496 times.
✗ Branch 3 not taken.
42496 if(!p_igetw(&tempDMap.minimap_1_tile,f))
4828 {
4829 return qe_invalid;
4830 }
4831 }
4832
4833
2/4
✓ Branch 0 taken 60416 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 60416 times.
✗ Branch 3 not taken.
60416 if(!p_getc(&tempDMap.minimap_1_cset,f))
4834 {
4835 return qe_invalid;
4836 }
4837
4838
2/4
✓ Branch 0 taken 60416 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 60416 times.
60416 if(Header && (Header->zelda_version < 0x193))
4839 {
4840 if(!p_getc(&padding,f))
4841 {
4842 return qe_invalid;
4843 }
4844 }
4845
4846
2/2
✓ Branch 0 taken 17920 times.
✓ Branch 1 taken 42496 times.
60416 if ( s_version >= 11 )
4847 {
4848
2/4
✓ Branch 0 taken 17920 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 17920 times.
✗ Branch 3 not taken.
17920 if(!p_igetl(&tempDMap.minimap_2_tile,f))
4849 {
4850 return qe_invalid;
4851 }
4852 17920 }
4853 else
4854 {
4855
2/4
✓ Branch 0 taken 42496 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 42496 times.
✗ Branch 3 not taken.
42496 if(!p_igetw(&tempDMap.minimap_2_tile,f))
4856 {
4857 return qe_invalid;
4858 }
4859 }
4860
2/4
✓ Branch 0 taken 60416 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 60416 times.
✗ Branch 3 not taken.
60416 if(!p_getc(&tempDMap.minimap_2_cset,f))
4861 {
4862 return qe_invalid;
4863 }
4864
4865
2/4
✓ Branch 0 taken 60416 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 60416 times.
60416 if(Header && (Header->zelda_version < 0x193))
4866 {
4867 if(!p_getc(&padding,f))
4868 {
4869 return qe_invalid;
4870 }
4871 }
4872
4873
2/2
✓ Branch 0 taken 17920 times.
✓ Branch 1 taken 42496 times.
60416 if ( s_version >= 11 )
4874 {
4875
2/4
✓ Branch 0 taken 17920 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 17920 times.
17920 if(!p_igetl(&tempDMap.largemap_1_tile,f))
4876 {
4877 return qe_invalid;
4878 }
4879 17920 }
4880 else
4881 {
4882
2/4
✓ Branch 0 taken 42496 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 42496 times.
42496 if(!p_igetw(&tempDMap.largemap_1_tile,f))
4883 {
4884 return qe_invalid;
4885 }
4886 }
4887
4888
2/4
✓ Branch 0 taken 60416 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 60416 times.
✗ Branch 3 not taken.
60416 if(!p_getc(&tempDMap.largemap_1_cset,f))
4889 {
4890 return qe_invalid;
4891 }
4892
4893
2/4
✓ Branch 0 taken 60416 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 60416 times.
60416 if(Header && (Header->zelda_version < 0x193))
4894 {
4895
4896 if(!p_getc(&padding,f))
4897 {
4898 return qe_invalid;
4899 }
4900 }
4901
4902
2/2
✓ Branch 0 taken 17920 times.
✓ Branch 1 taken 42496 times.
60416 if ( s_version >= 11 )
4903 {
4904
2/4
✓ Branch 0 taken 17920 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 17920 times.
✗ Branch 3 not taken.
17920 if(!p_igetl(&tempDMap.largemap_2_tile,f))
4905 {
4906 return qe_invalid;
4907 }
4908 17920 }
4909 else
4910 {
4911
2/4
✓ Branch 0 taken 42496 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 42496 times.
✗ Branch 3 not taken.
42496 if(!p_igetw(&tempDMap.largemap_2_tile,f))
4912 {
4913 return qe_invalid;
4914 }
4915 }
4916
2/4
✓ Branch 0 taken 60416 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 60416 times.
✗ Branch 3 not taken.
60416 if(!p_getc(&tempDMap.largemap_2_cset,f))
4917 {
4918 return qe_invalid;
4919 }
4920
4921
2/4
✓ Branch 0 taken 60416 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 60416 times.
✗ Branch 3 not taken.
60416 if(!p_getstr(tempDMap.tmusic,sizeof(DMaps[0].tmusic)-1,f))
4922 {
4923 return qe_invalid;
4924 }
4925 }
4926
4927
2/2
✓ Branch 0 taken 57344 times.
✓ Branch 1 taken 3200 times.
60544 if(s_version>1)
4928 {
4929
2/4
✓ Branch 0 taken 57344 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 57344 times.
✗ Branch 3 not taken.
57344 if(!p_getc(&tempDMap.tmusictrack,f))
4930 {
4931 return qe_invalid;
4932 }
4933
4934
2/4
✓ Branch 0 taken 57344 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 57344 times.
✗ Branch 3 not taken.
57344 if(!p_getc(&tempDMap.active_subscreen,f))
4935 {
4936 return qe_invalid;
4937 }
4938
4939
2/4
✓ Branch 0 taken 57344 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 57344 times.
✗ Branch 3 not taken.
57344 if(!p_getc(&tempDMap.passive_subscreen,f))
4940 {
4941 return qe_invalid;
4942 }
4943 57344 }
4944
4945
2/2
✓ Branch 0 taken 57344 times.
✓ Branch 1 taken 3200 times.
60544 if(s_version>2)
4946 {
4947 byte di[32];
4948
4949
2/4
✓ Branch 0 taken 57344 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 57344 times.
✗ Branch 3 not taken.
57344 if(!pfread(&di, 32, f)) return qe_invalid;
4950
4951
2/2
✓ Branch 0 taken 14680064 times.
✓ Branch 1 taken 57344 times.
14737408 for(int32_t j=0; j<MAXITEMS; j++)
4952 {
4953
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 14680057 times.
14680064 if(di[j/8] & (1 << (j%8))) tempDMap.disableditems[j]=1;
4954 14680057 else tempDMap.disableditems[j]=0;
4955 14680064 }
4956 57344 }
4957
4958
2/2
✓ Branch 0 taken 57344 times.
✓ Branch 1 taken 3200 times.
60544 if(s_version >= 6)
4959 {
4960
2/4
✓ Branch 0 taken 57344 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 57344 times.
✗ Branch 3 not taken.
57344 if(!p_igetl(&tempDMap.flags,f))
4961 {
4962 return qe_invalid;
4963 }
4964 57344 }
4965
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3200 times.
3200 else if(s_version>3)
4966 {
4967 char temp;
4968
4969 if(!p_getc(&temp,f))
4970 {
4971 return qe_invalid;
4972 }
4973
4974 tempDMap.flags = temp;
4975 }
4976
3/8
✓ Branch 0 taken 816 times.
✓ Branch 1 taken 2384 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 816 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
3200 else if(tempDMap.level==0 && ((Header->zelda_version < 0x211) || ((Header->zelda_version == 0x211) && (Header->build<18))))
4977 {
4978 816 tempDMap.flags=dmfCAVES|dmf3STAIR|dmfWHIRLWIND|dmfGUYCAVES;
4979 816 }
4980 else
4981 2384 tempDMap.flags=0;
4982
4983
2/2
✓ Branch 0 taken 57344 times.
✓ Branch 1 taken 3200 times.
60544 if(s_version<7)
4984 {
4985
4/6
✓ Branch 0 taken 816 times.
✓ Branch 1 taken 2384 times.
✓ Branch 2 taken 816 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 816 times.
3200 if(tempDMap.level==0 && get_bit(deprecated_rules,14))
4986 816 tempDMap.flags|= dmfVIEWMAP;
4987 3200 }
4988
4989
2/2
✓ Branch 0 taken 57344 times.
✓ Branch 1 taken 3200 times.
60544 if(s_version<8)
4990 {
4991
4/4
✓ Branch 0 taken 816 times.
✓ Branch 1 taken 2384 times.
✓ Branch 2 taken 207 times.
✓ Branch 3 taken 609 times.
3200 if(tempDMap.level==0 && (tempDMap.type&dmfTYPE)==dmDNGN)
4992 {
4993 609 tempDMap.type &= ~dmDNGN;
4994 609 tempDMap.type |= dmCAVE;
4995 609 }
4996
2/2
✓ Branch 0 taken 855 times.
✓ Branch 1 taken 1736 times.
2591 else if((tempDMap.type&dmfTYPE)==dmCAVE)
4997 {
4998 1736 tempDMap.flags |= dmfMINIMAPCOLORFIX;
4999 1736 }
5000 3200 }
5001
5002
5/8
✓ Branch 0 taken 60544 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 128 times.
✓ Branch 3 taken 60416 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 128 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 60416 times.
60544 if(Header && ((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>=41)))
5003 60416 && (Header->zelda_version < 0x193))
5004 {
5005 if(!p_getc(&padding,f))
5006 {
5007 return qe_invalid;
5008 }
5009 }
5010
5011
2/2
✓ Branch 0 taken 42624 times.
✓ Branch 1 taken 17920 times.
60544 if(s_version >= 10)
5012 {
5013
2/4
✓ Branch 0 taken 17920 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 17920 times.
✗ Branch 3 not taken.
17920 if(!p_getc(&tempDMap.sideview,f))
5014 {
5015 return qe_invalid;
5016 }
5017 17920 }
5018
2/2
✓ Branch 0 taken 17920 times.
✓ Branch 1 taken 42624 times.
60544 if(s_version < 10) tempDMap.sideview = 0;
5019
5020 //Dmap Scripts
5021
2/2
✓ Branch 0 taken 17920 times.
✓ Branch 1 taken 42624 times.
60544 if(s_version >= 12)
5022 {
5023
2/4
✓ Branch 0 taken 17920 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 17920 times.
✗ Branch 3 not taken.
17920 if(!p_igetw(&tempDMap.script,f))
5024 {
5025 return qe_invalid;
5026 }
5027
2/2
✓ Branch 0 taken 143360 times.
✓ Branch 1 taken 17920 times.
161280 for ( int32_t q = 0; q < 8; q++ )
5028 {
5029
2/4
✓ Branch 0 taken 143360 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 143360 times.
✗ Branch 3 not taken.
143360 if(!p_igetl(&tempDMap.initD[q],f))
5030 {
5031 return qe_invalid;
5032 }
5033 143360 }
5034 17920 }
5035
2/2
✓ Branch 0 taken 17920 times.
✓ Branch 1 taken 42624 times.
60544 if ( s_version < 12 )
5036 {
5037 42624 tempDMap.script = 0;
5038
2/2
✓ Branch 0 taken 340992 times.
✓ Branch 1 taken 42624 times.
383616 for ( int32_t q = 0; q < 8; q++ )
5039 {
5040 340992 tempDMap.initD[q] = 0;
5041 340992 }
5042 42624 }
5043
5044
2/2
✓ Branch 0 taken 42624 times.
✓ Branch 1 taken 17920 times.
60544 if(s_version >= 13)
5045 {
5046
2/2
✓ Branch 0 taken 143360 times.
✓ Branch 1 taken 17920 times.
161280 for ( int32_t q = 0; q < 8; q++ )
5047 {
5048
2/2
✓ Branch 0 taken 9318400 times.
✓ Branch 1 taken 143360 times.
9461760 for ( int32_t w = 0; w < 65; w++ )
5049 {
5050
2/4
✓ Branch 0 taken 9318400 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9318400 times.
✗ Branch 3 not taken.
9318400 if(!p_getc(&tempDMap.initD_label[q][w],f))
5051 {
5052 return qe_invalid;
5053 }
5054 9318400 }
5055 143360 }
5056 17920 }
5057
2/2
✓ Branch 0 taken 17920 times.
✓ Branch 1 taken 42624 times.
60544 if ( s_version < 13 )
5058 {
5059 42624 tempDMap.script = 0;
5060
2/2
✓ Branch 0 taken 340992 times.
✓ Branch 1 taken 42624 times.
383616 for ( int32_t q = 0; q < 8; q++ )
5061 {
5062
2/2
✓ Branch 0 taken 22164480 times.
✓ Branch 1 taken 340992 times.
22505472 for ( int32_t w = 0; w < 65; w++ )
5063 22164480 tempDMap.initD_label[q][w] = 0;
5064 340992 }
5065 42624 }
5066
2/2
✓ Branch 0 taken 17920 times.
✓ Branch 1 taken 42624 times.
60544 if(s_version >= 14)
5067 {
5068
2/4
✓ Branch 0 taken 17920 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 17920 times.
✗ Branch 3 not taken.
17920 if(!p_igetw(&tempDMap.active_sub_script,f))
5069 {
5070 return qe_invalid;
5071 }
5072
2/4
✓ Branch 0 taken 17920 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 17920 times.
✗ Branch 3 not taken.
17920 if(!p_igetw(&tempDMap.passive_sub_script,f))
5073 {
5074 return qe_invalid;
5075 }
5076
2/2
✓ Branch 0 taken 143360 times.
✓ Branch 1 taken 17920 times.
161280 for ( int32_t q = 0; q < 8; ++q )
5077 {
5078
2/4
✓ Branch 0 taken 143360 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 143360 times.
✗ Branch 3 not taken.
143360 if(!p_igetl(&tempDMap.sub_initD[q],f))
5079 {
5080 return qe_invalid;
5081 }
5082 143360 }
5083
2/2
✓ Branch 0 taken 143360 times.
✓ Branch 1 taken 17920 times.
161280 for(int32_t q = 0; q < 8; ++q)
5084 {
5085
2/2
✓ Branch 0 taken 9318400 times.
✓ Branch 1 taken 143360 times.
9461760 for ( int32_t w = 0; w < 65; ++w )
5086 {
5087
2/4
✓ Branch 0 taken 9318400 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9318400 times.
✗ Branch 3 not taken.
9318400 if(!p_getc(&tempDMap.sub_initD_label[q][w],f))
5088 {
5089 return qe_invalid;
5090 }
5091 9318400 }
5092 143360 }
5093 17920 }
5094 else
5095 {
5096 42624 tempDMap.active_sub_script = 0;
5097 42624 tempDMap.passive_sub_script = 0;
5098
2/2
✓ Branch 0 taken 340992 times.
✓ Branch 1 taken 42624 times.
383616 for(int32_t q = 0; q < 8; ++q)
5099 {
5100 340992 tempDMap.sub_initD[q] = 0;
5101
2/2
✓ Branch 0 taken 22164480 times.
✓ Branch 1 taken 340992 times.
22505472 for(int32_t w = 0; w < 65; ++w)
5102 22164480 tempDMap.sub_initD_label[q][w] = 0;
5103 340992 }
5104 }
5105
2/2
✓ Branch 0 taken 17920 times.
✓ Branch 1 taken 42624 times.
60544 if(s_version >= 15)
5106 {
5107
2/4
✓ Branch 0 taken 17920 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 17920 times.
✗ Branch 3 not taken.
17920 if(!p_igetw(&tempDMap.onmap_script,f))
5108 {
5109 return qe_invalid;
5110 }
5111
2/2
✓ Branch 0 taken 143360 times.
✓ Branch 1 taken 17920 times.
161280 for ( int32_t q = 0; q < 8; ++q )
5112 {
5113
2/4
✓ Branch 0 taken 143360 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 143360 times.
✗ Branch 3 not taken.
143360 if(!p_igetl(&tempDMap.onmap_initD[q],f))
5114 {
5115 return qe_invalid;
5116 }
5117 143360 }
5118
2/2
✓ Branch 0 taken 143360 times.
✓ Branch 1 taken 17920 times.
161280 for(int32_t q = 0; q < 8; ++q)
5119 {
5120
2/2
✓ Branch 0 taken 9318400 times.
✓ Branch 1 taken 143360 times.
9461760 for ( int32_t w = 0; w < 65; ++w )
5121 {
5122
2/4
✓ Branch 0 taken 9318400 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9318400 times.
✗ Branch 3 not taken.
9318400 if(!p_getc(&tempDMap.onmap_initD_label[q][w],f))
5123 {
5124 return qe_invalid;
5125 }
5126 9318400 }
5127 143360 }
5128 17920 }
5129 else
5130 {
5131 42624 tempDMap.onmap_script = 0;
5132
2/2
✓ Branch 0 taken 340992 times.
✓ Branch 1 taken 42624 times.
383616 for(int32_t q = 0; q < 8; ++q)
5133 {
5134 340992 tempDMap.onmap_initD[q] = 0;
5135
2/2
✓ Branch 0 taken 22164480 times.
✓ Branch 1 taken 340992 times.
22505472 for(int32_t w = 0; w < 65; ++w)
5136 {
5137 22164480 tempDMap.onmap_initD_label[q][w] = 0;
5138 22164480 }
5139 340992 }
5140 }
5141
2/2
✓ Branch 0 taken 17920 times.
✓ Branch 1 taken 42624 times.
60544 if(s_version >= 16)
5142 {
5143
2/4
✓ Branch 0 taken 17920 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 17920 times.
✗ Branch 3 not taken.
17920 if(!p_igetw(&tempDMap.mirrorDMap,f))
5144 {
5145 return qe_invalid;
5146 }
5147 17920 }
5148 else
5149 {
5150 42624 tempDMap.mirrorDMap = -1;
5151 }
5152
5153
2/2
✓ Branch 0 taken 47232 times.
✓ Branch 1 taken 13312 times.
60544 if (s_version >= 17)
5154 {
5155 // Reserved for z3.
5156 13312 }
5157
5158 // Enhanced music loop points
5159
2/2
✓ Branch 0 taken 13312 times.
✓ Branch 1 taken 47232 times.
60544 if (s_version >= 18)
5160 {
5161
2/4
✓ Branch 0 taken 13312 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 13312 times.
✗ Branch 3 not taken.
13312 if (!p_igetl(&tempDMap.tmusic_loop_start, f))
5162 {
5163 return qe_invalid;
5164 }
5165
2/4
✓ Branch 0 taken 13312 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 13312 times.
✗ Branch 3 not taken.
13312 if (!p_igetl(&tempDMap.tmusic_loop_end, f))
5166 {
5167 return qe_invalid;
5168 }
5169
2/4
✓ Branch 0 taken 13312 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 13312 times.
✗ Branch 3 not taken.
13312 if (!p_igetl(&tempDMap.tmusic_xfade_in, f))
5170 {
5171 return qe_invalid;
5172 }
5173
2/4
✓ Branch 0 taken 13312 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 13312 times.
✗ Branch 3 not taken.
13312 if (!p_igetl(&tempDMap.tmusic_xfade_out, f))
5174 {
5175 return qe_invalid;
5176 }
5177 13312 }
5178 else
5179 {
5180 47232 tempDMap.tmusic_loop_start = 0;
5181 47232 tempDMap.tmusic_loop_end = 0;
5182 47232 tempDMap.tmusic_xfade_in = 0;
5183 47232 tempDMap.tmusic_xfade_out = 0;
5184 }
5185
5186
2/2
✓ Branch 0 taken 13312 times.
✓ Branch 1 taken 47232 times.
60544 if(s_version >= 19)
5187
2/4
✓ Branch 0 taken 13312 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 13312 times.
✗ Branch 3 not taken.
13312 if(!p_getc(&tempDMap.overlay_subscreen, f))
5188 return qe_invalid;
5189
5190
2/2
✓ Branch 0 taken 4096 times.
✓ Branch 1 taken 56448 times.
60544 if (s_version >= 20)
5191 {
5192
2/4
✓ Branch 0 taken 4096 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4096 times.
✗ Branch 3 not taken.
4096 if (!p_igetl(&tempDMap.intro_string_id, f))
5193 return qe_invalid;
5194 4096 }
5195 else
5196 56448 tempDMap.intro_string_id = 0;
5197
5198 // Reserved for z3.
5199
2/2
✓ Branch 0 taken 56448 times.
✓ Branch 1 taken 4096 times.
60544 if(s_version >= 21)
5200 {
5201
2/2
✓ Branch 0 taken 32768 times.
✓ Branch 1 taken 4096 times.
36864 for(int32_t j=0; j<8; j++)
5202 {
5203
2/2
✓ Branch 0 taken 262144 times.
✓ Branch 1 taken 32768 times.
294912 for(int32_t k=0; k<8; k++)
5204 {
5205 char c;
5206
2/4
✓ Branch 0 taken 262144 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 262144 times.
✗ Branch 3 not taken.
262144 if(!p_getc(&c,f))
5207 {
5208 return qe_invalid;
5209 }
5210 262144 }
5211 32768 }
5212 4096 }
5213
5214
1/2
✓ Branch 0 taken 60544 times.
✗ Branch 1 not taken.
60544 if (!should_skip)
5215 {
5216
1/2
✓ Branch 0 taken 60544 times.
✗ Branch 1 not taken.
60544 if(loading_tileset_flags & TILESET_CLEARMAPS)
5217 tempDMap.map = 0;
5218
1/2
✓ Branch 0 taken 60544 times.
✗ Branch 1 not taken.
60544 if(loading_tileset_flags & TILESET_CLEARSCRIPTS)
5219 {
5220 tempDMap.script = 0;
5221 for(int q = 0; q < 8; ++q)
5222 tempDMap.initD[q] = 0;
5223 }
5224
1/2
✓ Branch 0 taken 60544 times.
✗ Branch 1 not taken.
60544 DMaps[i] = tempDMap;
5225 60544 }
5226 60544 }
5227
5228 128 return 0;
5229 128 }
5230
5231 112 int32_t readmisccolors(PACKFILE *f, zquestheader *Header, miscQdata *Misc)
5232 {
5233 //these are here to bypass compiler warnings about unused arguments
5234 112 Header=Header;
5235
5236 miscQdata temp_misc;
5237 112 word s_version=0, s_cversion=0;
5238 112 int32_t tempsize=0;
5239 word dummyw;
5240
5241 112 memcpy(&temp_misc,Misc,sizeof(temp_misc));
5242
5243 //section version info
5244
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 112 times.
112 if(!p_igetw(&s_version,f))
5245 {
5246 return qe_invalid;
5247 }
5248
5249 112 FFCore.quest_format[vColours] = s_version;
5250
5251 112 al_trace("Misc Colours section version: %d\n", s_version);
5252
5253 //al_trace("Misc. colors version %d\n", s_version);
5254
1/2
✓ Branch 0 taken 112 times.
✗ Branch 1 not taken.
112 if(!p_igetw(&s_cversion,f))
5255 {
5256 return qe_invalid;
5257 }
5258
5259
5260 //section size
5261
1/2
✓ Branch 0 taken 112 times.
✗ Branch 1 not taken.
112 if(!p_igetl(&tempsize,f))
5262 {
5263 return qe_invalid;
5264 }
5265
5266 //finally... section data
5267 112 readsize=0;
5268
5269
1/2
✓ Branch 0 taken 112 times.
✗ Branch 1 not taken.
112 if(!p_getc(&temp_misc.colors.text,f))
5270 {
5271 return qe_invalid;
5272 }
5273
5274
1/2
✓ Branch 0 taken 112 times.
✗ Branch 1 not taken.
112 if(!p_getc(&temp_misc.colors.caption,f))
5275 {
5276 return qe_invalid;
5277 }
5278
5279
1/2
✓ Branch 0 taken 112 times.
✗ Branch 1 not taken.
112 if(!p_getc(&temp_misc.colors.overw_bg,f))
5280 {
5281 return qe_invalid;
5282 }
5283
5284
1/2
✓ Branch 0 taken 112 times.
✗ Branch 1 not taken.
112 if(!p_getc(&temp_misc.colors.dngn_bg,f))
5285 {
5286 return qe_invalid;
5287 }
5288
5289
1/2
✓ Branch 0 taken 112 times.
✗ Branch 1 not taken.
112 if(!p_getc(&temp_misc.colors.dngn_fg,f))
5290 {
5291 return qe_invalid;
5292 }
5293
5294
1/2
✓ Branch 0 taken 112 times.
✗ Branch 1 not taken.
112 if(!p_getc(&temp_misc.colors.cave_fg,f))
5295 {
5296 return qe_invalid;
5297 }
5298
5299
1/2
✓ Branch 0 taken 112 times.
✗ Branch 1 not taken.
112 if(!p_getc(&temp_misc.colors.bs_dk,f))
5300 {
5301 return qe_invalid;
5302 }
5303
5304
1/2
✓ Branch 0 taken 112 times.
✗ Branch 1 not taken.
112 if(!p_getc(&temp_misc.colors.bs_goal,f))
5305 {
5306 return qe_invalid;
5307 }
5308
5309
1/2
✓ Branch 0 taken 112 times.
✗ Branch 1 not taken.
112 if(!p_getc(&temp_misc.colors.compass_lt,f))
5310 {
5311 return qe_invalid;
5312 }
5313
5314
1/2
✓ Branch 0 taken 112 times.
✗ Branch 1 not taken.
112 if(!p_getc(&temp_misc.colors.compass_dk,f))
5315 {
5316 return qe_invalid;
5317 }
5318
5319
1/2
✓ Branch 0 taken 112 times.
✗ Branch 1 not taken.
112 if(!p_getc(&temp_misc.colors.subscr_bg,f))
5320 {
5321 return qe_invalid;
5322 }
5323
5324
1/2
✓ Branch 0 taken 112 times.
✗ Branch 1 not taken.
112 if(!p_getc(&temp_misc.colors.triframe_color,f))
5325 {
5326 return qe_invalid;
5327 }
5328
5329
1/2
✓ Branch 0 taken 112 times.
✗ Branch 1 not taken.
112 if(!p_getc(&temp_misc.colors.hero_dot,f))
5330 {
5331 return qe_invalid;
5332 }
5333
5334
1/2
✓ Branch 0 taken 112 times.
✗ Branch 1 not taken.
112 if(!p_getc(&temp_misc.colors.bmap_bg,f))
5335 {
5336 return qe_invalid;
5337 }
5338
5339
1/2
✓ Branch 0 taken 112 times.
✗ Branch 1 not taken.
112 if(!p_getc(&temp_misc.colors.bmap_fg,f))
5340 {
5341 return qe_invalid;
5342 }
5343
5344
1/2
✓ Branch 0 taken 112 times.
✗ Branch 1 not taken.
112 if(!p_getc(&temp_misc.colors.triforce_cset,f))
5345 {
5346 return qe_invalid;
5347 }
5348
5349
1/2
✓ Branch 0 taken 112 times.
✗ Branch 1 not taken.
112 if(!p_getc(&temp_misc.colors.triframe_cset,f))
5350 {
5351 return qe_invalid;
5352 }
5353
5354
1/2
✓ Branch 0 taken 112 times.
✗ Branch 1 not taken.
112 if(!p_getc(&temp_misc.colors.overworld_map_cset,f))
5355 {
5356 return qe_invalid;
5357 }
5358
5359
1/2
✓ Branch 0 taken 112 times.
✗ Branch 1 not taken.
112 if(!p_getc(&temp_misc.colors.dungeon_map_cset,f))
5360 {
5361 return qe_invalid;
5362 }
5363
5364
1/2
✓ Branch 0 taken 112 times.
✗ Branch 1 not taken.
112 if(!p_getc(&temp_misc.colors.blueframe_cset,f))
5365 {
5366 return qe_invalid;
5367 }
5368
2/2
✓ Branch 0 taken 35 times.
✓ Branch 1 taken 77 times.
112 if(s_version < 4)
5369 {
5370
1/2
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
77 if(!p_igetw(&dummyw,f))
5371 return qe_invalid;
5372 77 temp_misc.colors.triforce_tile = dummyw;
5373
5374
1/2
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
77 if(!p_igetw(&dummyw,f))
5375 return qe_invalid;
5376 77 temp_misc.colors.triframe_tile = dummyw;
5377
5378
1/2
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
77 if(!p_igetw(&dummyw,f))
5379 return qe_invalid;
5380 77 temp_misc.colors.overworld_map_tile = dummyw;
5381
5382
1/2
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
77 if(!p_igetw(&dummyw,f))
5383 return qe_invalid;
5384 77 temp_misc.colors.dungeon_map_tile = dummyw;
5385
5386
1/2
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
77 if(!p_igetw(&dummyw,f))
5387 return qe_invalid;
5388 77 temp_misc.colors.blueframe_tile = dummyw;
5389
5390
1/2
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
77 if(!p_igetw(&dummyw,f))
5391 return qe_invalid;
5392 77 temp_misc.colors.HCpieces_tile = dummyw;
5393 77 }
5394
5395
1/2
✓ Branch 0 taken 112 times.
✗ Branch 1 not taken.
112 if(!p_getc(&temp_misc.colors.HCpieces_cset,f))
5396 {
5397 return qe_invalid;
5398 }
5399
5400
1/2
✓ Branch 0 taken 112 times.
✗ Branch 1 not taken.
112 if(!p_getc(&temp_misc.colors.subscr_shadow,f))
5401 {
5402 return qe_invalid;
5403 }
5404
5405
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 112 times.
112 if(s_version < 2)
5406 {
5407 temp_misc.colors.msgtext = 0x01;
5408 }
5409 else
5410 {
5411
1/2
✓ Branch 0 taken 112 times.
✗ Branch 1 not taken.
112 if(!p_getc(&temp_misc.colors.msgtext, f))
5412 {
5413 return qe_invalid;
5414 }
5415 }
5416
5417
2/2
✓ Branch 0 taken 77 times.
✓ Branch 1 taken 35 times.
112 if ( s_version >= 3 ) //expanded tile pages to 825
5418 {
5419
1/2
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
35 if(!p_igetl(&temp_misc.colors.triforce_tile,f))
5420 {
5421 return qe_invalid;
5422 }
5423
5424
1/2
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
35 if(!p_igetl(&temp_misc.colors.triframe_tile,f))
5425 {
5426 return qe_invalid;
5427 }
5428
5429
1/2
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
35 if(!p_igetl(&temp_misc.colors.overworld_map_tile,f))
5430 {
5431 return qe_invalid;
5432 }
5433
5434
1/2
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
35 if(!p_igetl(&temp_misc.colors.dungeon_map_tile,f))
5435 {
5436 return qe_invalid;
5437 }
5438
5439
1/2
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
35 if(!p_igetl(&temp_misc.colors.blueframe_tile,f))
5440 {
5441 return qe_invalid;
5442 }
5443
5444
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 35 times.
35 if(!p_igetl(&temp_misc.colors.HCpieces_tile,f))
5445 {
5446 return qe_invalid;
5447 }
5448 35 }
5449
5450 112 memcpy(Misc, &temp_misc, sizeof(temp_misc));
5451
5452 112 return 0;
5453 112 }
5454
5455 112 int32_t readgameicons(PACKFILE *f, zquestheader *, miscQdata *Misc)
5456 {
5457 miscQdata temp_misc;
5458 112 word s_version=0, s_cversion=0;
5459 byte icons;
5460 112 int32_t tempsize=0;
5461
5462 112 memcpy(&temp_misc,Misc,sizeof(temp_misc));
5463
5464 //section version info
5465
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 112 times.
112 if(!p_igetw(&s_version,f))
5466 {
5467 return qe_invalid;
5468 }
5469
5470 112 FFCore.quest_format[vIcons] = s_version;
5471
5472 //al_trace("Game icons version %d\n", s_version);
5473
1/2
✓ Branch 0 taken 112 times.
✗ Branch 1 not taken.
112 if(!p_igetw(&s_cversion,f))
5474 {
5475 return qe_invalid;
5476 }
5477
5478
5479 //section size
5480
1/2
✓ Branch 0 taken 112 times.
✗ Branch 1 not taken.
112 if(!p_igetl(&tempsize,f))
5481 {
5482 return qe_invalid;
5483 }
5484
5485 //finally... section data
5486 112 readsize=0;
5487
5488 112 icons=4;
5489
5490
2/2
✓ Branch 0 taken 35 times.
✓ Branch 1 taken 77 times.
112 if ( s_version >= 10 )
5491 {
5492
2/2
✓ Branch 0 taken 140 times.
✓ Branch 1 taken 35 times.
175 for(int32_t i=0; i<icons; i++)
5493 {
5494
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 140 times.
140 if(!p_igetl(&temp_misc.icons[i],f))
5495 {
5496 return qe_invalid;
5497 }
5498 140 }
5499 35 }
5500 else
5501 {
5502
2/2
✓ Branch 0 taken 308 times.
✓ Branch 1 taken 77 times.
385 for(int32_t i=0; i<icons; i++)
5503 {
5504
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 308 times.
308 if(!p_igetw(&temp_misc.icons[i],f))
5505 {
5506 return qe_invalid;
5507 }
5508 308 }
5509 }
5510
5511 112 memcpy(Misc, &temp_misc, sizeof(temp_misc));
5512
5513 112 return 0;
5514 112 }
5515
5516 128 int32_t readmisc(PACKFILE *f, zquestheader *Header, miscQdata *Misc)
5517 {
5518
2/2
✓ Branch 0 taken 124 times.
✓ Branch 1 taken 4 times.
128 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_misc);
5519
5520 128 word maxinfos=256;
5521 128 word maxshops=256;
5522 128 word shops=16, infos=16, warprings=8, palcycles=256, windwarps=9, triforces=8, icons=4;
5523 128 word ponds=16, pondsize=72, expansionsize=98*2;
5524 byte tempbyte, padding;
5525 miscQdata temp_misc;
5526 128 word s_version=0, s_cversion=0;
5527 word swaptmp;
5528 128 int32_t tempsize=0;
5529
5530 128 memcpy(&temp_misc,Misc,sizeof(temp_misc));
5531
5532
2/2
✓ Branch 0 taken 32768 times.
✓ Branch 1 taken 128 times.
32896 for(int32_t i=0; i<maxshops; ++i)
5533 {
5534 32768 memset(&temp_misc.shop, 0, sizeof(shoptype)*256);
5535 32768 }
5536
5537
2/2
✓ Branch 0 taken 32768 times.
✓ Branch 1 taken 128 times.
32896 for(int32_t i=0; i<maxinfos; ++i)
5538 {
5539 32768 memset(&temp_misc.info, 0, sizeof(infotype)*256);
5540 32768 }
5541
5542
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 124 times.
128 if(Header->zelda_version > 0x192)
5543 {
5544 //section version info
5545
1/2
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
124 if(!p_igetw(&s_version,f))
5546 {
5547 return qe_invalid;
5548 }
5549
5550 124 FFCore.quest_format[vMisc] = s_version;
5551
5552 //al_trace("Misc. data version %d\n", s_version);
5553
1/2
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
124 if(!p_igetw(&s_cversion,f))
5554 {
5555 return qe_invalid;
5556 }
5557
5558
5559 //section size
5560
1/2
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
124 if(!p_igetl(&tempsize,f))
5561 {
5562 return qe_invalid;
5563 }
5564 124 }
5565
5566 //finally... section data
5567 128 readsize=0;
5568
5569 //shops
5570
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 124 times.
128 if(Header->zelda_version > 0x192)
5571 {
5572
1/2
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
124 if(!p_igetw(&shops,f))
5573 {
5574 return qe_invalid;
5575 }
5576 124 }
5577
5578
2/4
✓ Branch 0 taken 128 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 128 times.
128 if (!(shops >= 0 && shops <= NUM_SHOPS))
5579 {
5580 return qe_invalid;
5581 }
5582
5583
2/2
✓ Branch 0 taken 1440 times.
✓ Branch 1 taken 128 times.
1568 for(int32_t i=0; i<shops; i++)
5584 {
5585
2/2
✓ Branch 0 taken 223 times.
✓ Branch 1 taken 1217 times.
1440 if(s_version > 6)
5586 {
5587
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1217 times.
1217 if(!p_getstr(temp_misc.shop[i].name,sizeof(temp_misc.shop[i].name)-1,f))
5588 {
5589 return qe_invalid;
5590 }
5591 1217 }
5592
5593
2/2
✓ Branch 0 taken 4320 times.
✓ Branch 1 taken 1440 times.
5760 for(int32_t j=0; j<3; j++)
5594 {
5595
1/2
✓ Branch 0 taken 4320 times.
✗ Branch 1 not taken.
4320 if(!p_getc(&temp_misc.shop[i].item[j],f))
5596 {
5597 return qe_invalid;
5598 }
5599
5600
2/2
✓ Branch 0 taken 3651 times.
✓ Branch 1 taken 669 times.
4320 if(s_version < 4)
5601 {
5602 669 temp_misc.shop[i].hasitem[j] = (temp_misc.shop[i].item[j] == 0) ? 0 : 1;
5603 669 }
5604 4320 }
5605
5606
2/2
✓ Branch 0 taken 1376 times.
✓ Branch 1 taken 64 times.
1440 if(Header->zelda_version < 0x193)
5607 {
5608
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 64 times.
64 if(!p_getc(&tempbyte,f))
5609 {
5610 return qe_invalid;
5611 }
5612 64 }
5613
5614
2/2
✓ Branch 0 taken 4320 times.
✓ Branch 1 taken 1440 times.
5760 for(int32_t j=0; j<3; j++)
5615 {
5616
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4320 times.
4320 if(!p_igetw(&temp_misc.shop[i].price[j],f))
5617 {
5618 return qe_invalid;
5619 }
5620 4320 }
5621
5622
2/2
✓ Branch 0 taken 223 times.
✓ Branch 1 taken 1217 times.
1440 if(s_version > 3)
5623 {
5624
2/2
✓ Branch 0 taken 3651 times.
✓ Branch 1 taken 1217 times.
4868 for(int32_t j=0; j<3; j++)
5625 {
5626
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3651 times.
3651 if(!p_getc(&temp_misc.shop[i].hasitem[j],f))
5627 return qe_invalid;
5628 3651 }
5629 1217 }
5630
5631 /*
5632 if(s_version < 8)
5633 {
5634 for(int32_t j=0; j<3; j++)
5635 {
5636 (&temp_misc.shop[i].str[j])=0; //initialise.
5637 }
5638 }
5639 */
5640 1440 }
5641
5642 //filter all the 0 items to the end (yeah, bubble sort; sue me)
5643
2/2
✓ Branch 0 taken 32768 times.
✓ Branch 1 taken 128 times.
32896 for(int32_t i=0; i<maxshops; ++i)
5644 {
5645
2/2
✓ Branch 0 taken 65536 times.
✓ Branch 1 taken 32768 times.
98304 for(int32_t j=0; j<3-1; j++)
5646 {
5647
2/2
✓ Branch 0 taken 65536 times.
✓ Branch 1 taken 95331 times.
160867 for(int32_t k=0; k<2-j; k++)
5648 {
5649 95331 if(temp_misc.shop[i].hasitem[k]==0)
5650 {
5651 95331 swaptmp = temp_misc.shop[i].item[k];
5652 95331 temp_misc.shop[i].item[k] = temp_misc.shop[i].item[k+1];
5653 95331 temp_misc.shop[i].item[k+1] = swaptmp;
5654 95331 swaptmp = temp_misc.shop[i].price[k];
5655 95331 temp_misc.shop[i].price[k] = temp_misc.shop[i].price[k+1];
5656 95331 temp_misc.shop[i].price[k+1] = swaptmp;
5657 95331 swaptmp = temp_misc.shop[i].hasitem[k];
5658 95331 temp_misc.shop[i].hasitem[k] = temp_misc.shop[i].hasitem[k+1];
5659 95331 temp_misc.shop[i].hasitem[k+1] = swaptmp;
5660 95331 }
5661 95331 }
5662 65536 }
5663 32768 }
5664
5665 //infos
5666
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 124 times.
128 if(Header->zelda_version > 0x192)
5667 {
5668
1/2
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
124 if(!p_igetw(&infos,f))
5669 {
5670 return qe_invalid;
5671 }
5672 124 }
5673
5674
2/4
✓ Branch 0 taken 128 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 128 times.
128 if (!(infos >= 0 && infos <= NUM_INFOS))
5675 {
5676 return qe_invalid;
5677 }
5678
5679
5680
2/2
✓ Branch 0 taken 1751 times.
✓ Branch 1 taken 128 times.
1879 for(int32_t i=0; i<infos; i++)
5681 {
5682
2/2
✓ Branch 0 taken 100 times.
✓ Branch 1 taken 1651 times.
1751 if(s_version > 6)
5683 {
5684
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1651 times.
1651 if(!p_getstr(temp_misc.info[i].name,sizeof(temp_misc.info[i].name)-1,f))
5685 {
5686 return qe_invalid;
5687 }
5688 1651 }
5689
5690
2/2
✓ Branch 0 taken 5253 times.
✓ Branch 1 taken 1751 times.
7004 for(int32_t j=0; j<3; j++)
5691 {
5692
2/4
✓ Branch 0 taken 5061 times.
✓ Branch 1 taken 192 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
5253 if((Header->zelda_version < 0x192)||
5693
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5061 times.
5061 ((Header->zelda_version == 0x192)&&(Header->build<146)))
5694 {
5695
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 192 times.
192 if(!p_getc(&tempbyte,f))
5696 {
5697 return qe_invalid;
5698 }
5699
5700 192 temp_misc.info[i].str[j]=tempbyte;
5701 192 }
5702 else
5703 {
5704
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5061 times.
5061 if(!p_igetw(&temp_misc.info[i].str[j],f))
5705 {
5706 return qe_invalid;
5707 }
5708 }
5709 5253 }
5710
5711
2/2
✓ Branch 0 taken 1687 times.
✓ Branch 1 taken 64 times.
1751 if(Header->zelda_version < 0x193)
5712 {
5713
1/2
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
64 if(!p_getc(&tempbyte,f))
5714 {
5715 return qe_invalid;
5716 }
5717 64 }
5718
5719
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1751 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1751 if((Header->zelda_version == 0x192)&&(Header->build>145))
5720 {
5721 if(!p_getc(&padding,f))
5722 {
5723 return qe_invalid;
5724 }
5725 }
5726
5727
2/2
✓ Branch 0 taken 5253 times.
✓ Branch 1 taken 1751 times.
7004 for(int32_t j=0; j<3; j++)
5728 {
5729
1/2
✓ Branch 0 taken 5253 times.
✗ Branch 1 not taken.
5253 if(!p_igetw(&temp_misc.info[i].price[j],f))
5730 {
5731 return qe_invalid;
5732 }
5733 5253 }
5734 1751 }
5735
5736 //filter all the 0 strings to the end (yeah, bubble sort; sue me)
5737
2/2
✓ Branch 0 taken 32768 times.
✓ Branch 1 taken 128 times.
32896 for(int32_t i=0; i<maxinfos; ++i)
5738 {
5739
2/2
✓ Branch 0 taken 65536 times.
✓ Branch 1 taken 32768 times.
98304 for(int32_t j=0; j<3-1; j++)
5740 {
5741
2/2
✓ Branch 0 taken 98304 times.
✓ Branch 1 taken 65536 times.
163840 for(int32_t k=0; k<2-j; k++)
5742 {
5743
2/2
✓ Branch 0 taken 2076 times.
✓ Branch 1 taken 96228 times.
98304 if(temp_misc.info[i].str[k]==0)
5744 {
5745 96228 swaptmp = temp_misc.info[i].str[k];
5746 96228 temp_misc.info[i].str[k] = temp_misc.info[i].str[k+1];
5747 96228 temp_misc.info[i].str[k+1] = swaptmp;
5748 96228 swaptmp = temp_misc.info[i].price[k];
5749 96228 temp_misc.info[i].price[k] = temp_misc.info[i].price[k+1];
5750 96228 temp_misc.info[i].price[k+1] = swaptmp;
5751 96228 }
5752 98304 }
5753 65536 }
5754 32768 }
5755
5756
5757 //warp rings
5758
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 112 times.
128 if(s_version > 5)
5759 112 warprings++;
5760
5761
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 124 times.
128 if(Header->zelda_version > 0x192)
5762 {
5763
1/2
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
124 if(!p_igetw(&warprings,f))
5764 {
5765 return qe_invalid;
5766 }
5767
5768
3/4
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 86 times.
✓ Branch 3 taken 38 times.
124 if (!(warprings >= 0 && warprings <= NUM_WARP_RINGS))
5769 {
5770 // return qe_invalid;
5771 // Note: we can't actually fail here because for some reason, some quest files have more than the max
5772 // number of possible warp rings. Some examples of this are: demosp253.qst, yuurand.qst
5773 // So instead below we disable `keepdata` when reading the bad warp ring data, so no memory is corrupted.
5774 38 }
5775 124 }
5776
5777
2/2
✓ Branch 0 taken 1289 times.
✓ Branch 1 taken 128 times.
1417 for(int32_t i=0; i<warprings; i++)
5778 {
5779 // See above comment on the `warprings` range check.
5780 1289 bool keepdata = i < NUM_WARP_RINGS;
5781
5782
2/2
✓ Branch 0 taken 11377 times.
✓ Branch 1 taken 1289 times.
12666 for(int32_t j=0; j<8+((s_version > 5)?1:0); j++)
5783 {
5784
2/2
✓ Branch 0 taken 1792 times.
✓ Branch 1 taken 9585 times.
11377 if(s_version <= 3)
5785 {
5786
1/2
✓ Branch 0 taken 1792 times.
✗ Branch 1 not taken.
1792 if(!p_getc(&tempbyte,f))
5787 {
5788 return qe_invalid;
5789 }
5790
5791
2/2
✓ Branch 0 taken 672 times.
✓ Branch 1 taken 1120 times.
1792 if (keepdata)
5792 1120 temp_misc.warp[i].dmap[j]=(word)tempbyte;
5793 1792 }
5794 else
5795 {
5796 word tempword;
5797
1/2
✓ Branch 0 taken 9585 times.
✗ Branch 1 not taken.
9585 if(!p_igetw(&tempword,f))
5798 {
5799 return qe_invalid;
5800 }
5801
5802
2/2
✓ Branch 0 taken 513 times.
✓ Branch 1 taken 9072 times.
9585 if (keepdata)
5803 9072 temp_misc.warp[i].dmap[j] = tempword;
5804 }
5805 11377 }
5806
5807
2/2
✓ Branch 0 taken 11377 times.
✓ Branch 1 taken 1289 times.
12666 for(int32_t j=0; j<8+((s_version > 5)?1:0); j++)
5808 {
5809
1/2
✓ Branch 0 taken 11377 times.
✗ Branch 1 not taken.
11377 if(!p_getc(&tempbyte,f))
5810 {
5811 return qe_invalid;
5812 }
5813
2/2
✓ Branch 0 taken 1185 times.
✓ Branch 1 taken 10192 times.
11377 if (keepdata)
5814 10192 temp_misc.warp[i].scr[j] = tempbyte;
5815 11377 }
5816
5817
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1289 times.
1289 if(!p_getc(&tempbyte,f))
5818 {
5819 return qe_invalid;
5820 }
5821
2/2
✓ Branch 0 taken 141 times.
✓ Branch 1 taken 1148 times.
1289 if (keepdata)
5822 1148 temp_misc.warp[i].size = tempbyte;
5823
5824
2/2
✓ Branch 0 taken 1257 times.
✓ Branch 1 taken 32 times.
1289 if(Header->zelda_version < 0x193)
5825 {
5826
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 32 times.
32 if(!p_getc(&tempbyte,f))
5827 {
5828 return qe_invalid;
5829 }
5830 32 }
5831 1289 }
5832
5833 //palette cycles
5834
2/2
✓ Branch 0 taken 124 times.
✓ Branch 1 taken 4 times.
128 if(Header->zelda_version < 0x193) //in 1.93+, palette cycling is saved with the palettes
5835 {
5836
2/2
✓ Branch 0 taken 1024 times.
✓ Branch 1 taken 4 times.
1028 for(int32_t i=0; i<256; i++)
5837 {
5838
2/2
✓ Branch 0 taken 3072 times.
✓ Branch 1 taken 1024 times.
4096 for(int32_t j=0; j<3; j++)
5839 {
5840 3072 temp_misc.cycles[i][j].first=0;
5841 3072 temp_misc.cycles[i][j].count=0;
5842 3072 temp_misc.cycles[i][j].speed=0;
5843 3072 }
5844 1024 }
5845
5846
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
4 if((Header->zelda_version < 0x192)||
5847 ((Header->zelda_version == 0x192)&&(Header->build<73)))
5848 {
5849 4 palcycles=16;
5850 4 }
5851
5852
2/2
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 4 times.
68 for(int32_t i=0; i<palcycles; i++)
5853 {
5854
2/2
✓ Branch 0 taken 192 times.
✓ Branch 1 taken 64 times.
256 for(int32_t j=0; j<3; j++)
5855 {
5856
1/2
✓ Branch 0 taken 192 times.
✗ Branch 1 not taken.
192 if(!p_getc(&temp_misc.cycles[i][j].first,f))
5857 {
5858 return qe_invalid;
5859 }
5860
5861
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 192 times.
192 if(!p_getc(&temp_misc.cycles[i][j].count,f))
5862 {
5863 return qe_invalid;
5864 }
5865
5866
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 192 times.
192 if(!p_getc(&temp_misc.cycles[i][j].speed,f))
5867 {
5868 return qe_invalid;
5869 }
5870 192 }
5871 64 }
5872 4 }
5873
5874 //Wind warps are now just another warp ring.
5875
2/2
✓ Branch 0 taken 112 times.
✓ Branch 1 taken 16 times.
128 if(s_version <= 5)
5876 {
5877
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 12 times.
16 if(Header->zelda_version > 0x192)
5878 {
5879
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!p_igetw(&windwarps,f))
5880 {
5881 return qe_invalid;
5882 }
5883 12 }
5884
5885
2/4
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 16 times.
16 if (!(windwarps >= 0 && windwarps <= NUM_WARP_RINGS))
5886 {
5887 return qe_invalid;
5888 }
5889
5890
2/2
✓ Branch 0 taken 135 times.
✓ Branch 1 taken 16 times.
151 for(int32_t i=0; i<windwarps; i++)
5891 {
5892
1/2
✓ Branch 0 taken 135 times.
✗ Branch 1 not taken.
135 if(s_version <= 3)
5893 {
5894
1/2
✓ Branch 0 taken 135 times.
✗ Branch 1 not taken.
135 if(!p_getc(&tempbyte,f))
5895 {
5896 return qe_invalid;
5897 }
5898
5899 135 temp_misc.warp[8].dmap[i]=tempbyte;
5900 135 }
5901 else
5902 {
5903 if(!p_igetw(&temp_misc.warp[8].dmap[i],f))
5904 {
5905 return qe_invalid;
5906 }
5907 }
5908
5909
1/2
✓ Branch 0 taken 135 times.
✗ Branch 1 not taken.
135 if(!p_getc(&temp_misc.warp[8].scr[i],f))
5910 {
5911 return qe_invalid;
5912 }
5913
5914 135 temp_misc.warp[8].size = 9;
5915
5916
1/2
✓ Branch 0 taken 135 times.
✗ Branch 1 not taken.
135 if(s_version == 5)
5917 {
5918 if(!p_getc(&tempbyte,f))
5919 {
5920 return qe_invalid;
5921 }
5922 }
5923 135 }
5924 16 }
5925
5926
5927 //triforce pieces
5928
2/2
✓ Branch 0 taken 1024 times.
✓ Branch 1 taken 128 times.
1152 for(int32_t i=0; i<triforces; i++)
5929 {
5930
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1024 times.
1024 if(!p_getc(&temp_misc.triforce[i],f))
5931 {
5932 return qe_invalid;
5933 }
5934 1024 }
5935
5936 //misc color data
5937
2/2
✓ Branch 0 taken 112 times.
✓ Branch 1 taken 16 times.
128 if(s_version<3)
5938 {
5939
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!p_getc(&temp_misc.colors.text,f))
5940 {
5941 return qe_invalid;
5942 }
5943
5944
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!p_getc(&temp_misc.colors.caption,f))
5945 {
5946 return qe_invalid;
5947 }
5948
5949
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!p_getc(&temp_misc.colors.overw_bg,f))
5950 {
5951 return qe_invalid;
5952 }
5953
5954
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!p_getc(&temp_misc.colors.dngn_bg,f))
5955 {
5956 return qe_invalid;
5957 }
5958
5959
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!p_getc(&temp_misc.colors.dngn_fg,f))
5960 {
5961 return qe_invalid;
5962 }
5963
5964
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!p_getc(&temp_misc.colors.cave_fg,f))
5965 {
5966 return qe_invalid;
5967 }
5968
5969
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!p_getc(&temp_misc.colors.bs_dk,f))
5970 {
5971 return qe_invalid;
5972 }
5973
5974
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!p_getc(&temp_misc.colors.bs_goal,f))
5975 {
5976 return qe_invalid;
5977 }
5978
5979
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!p_getc(&temp_misc.colors.compass_lt,f))
5980 {
5981 return qe_invalid;
5982 }
5983
5984
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!p_getc(&temp_misc.colors.compass_dk,f))
5985 {
5986 return qe_invalid;
5987 }
5988
5989
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!p_getc(&temp_misc.colors.subscr_bg,f))
5990 {
5991 return qe_invalid;
5992 }
5993
5994
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!p_getc(&temp_misc.colors.triframe_color,f))
5995 {
5996 return qe_invalid;
5997 }
5998
5999
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!p_getc(&temp_misc.colors.hero_dot,f))
6000 {
6001 return qe_invalid;
6002 }
6003
6004
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!p_getc(&temp_misc.colors.bmap_bg,f))
6005 {
6006 return qe_invalid;
6007 }
6008
6009
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!p_getc(&temp_misc.colors.bmap_fg,f))
6010 {
6011 return qe_invalid;
6012 }
6013
6014
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!p_getc(&temp_misc.colors.triforce_cset,f))
6015 {
6016 return qe_invalid;
6017 }
6018
6019
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!p_getc(&temp_misc.colors.triframe_cset,f))
6020 {
6021 return qe_invalid;
6022 }
6023
6024
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!p_getc(&temp_misc.colors.overworld_map_cset,f))
6025 {
6026 return qe_invalid;
6027 }
6028
6029
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!p_getc(&temp_misc.colors.dungeon_map_cset,f))
6030 {
6031 return qe_invalid;
6032 }
6033
6034
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!p_getc(&temp_misc.colors.blueframe_cset,f))
6035 {
6036 return qe_invalid;
6037 }
6038
6039
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!p_igetw(&temp_misc.colors.triforce_tile,f))
6040 {
6041 return qe_invalid;
6042 }
6043
6044
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!p_igetw(&temp_misc.colors.triframe_tile,f))
6045 {
6046 return qe_invalid;
6047 }
6048
6049
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!p_igetw(&temp_misc.colors.overworld_map_tile,f))
6050 {
6051 return qe_invalid;
6052 }
6053
6054
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!p_igetw(&temp_misc.colors.dungeon_map_tile,f))
6055 {
6056 return qe_invalid;
6057 }
6058
6059
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!p_igetw(&temp_misc.colors.blueframe_tile,f))
6060 {
6061 return qe_invalid;
6062 }
6063
6064
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!p_igetw(&temp_misc.colors.HCpieces_tile,f))
6065 {
6066 return qe_invalid;
6067 }
6068
6069
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!p_getc(&temp_misc.colors.HCpieces_cset,f))
6070 {
6071 return qe_invalid;
6072 }
6073
6074 16 temp_misc.colors.msgtext = 0x01;
6075
6076
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 4 times.
16 if(Header->zelda_version < 0x193)
6077 {
6078
2/2
✓ Branch 0 taken 28 times.
✓ Branch 1 taken 4 times.
32 for(int32_t i=0; i<7; i++)
6079 {
6080
1/2
✓ Branch 0 taken 28 times.
✗ Branch 1 not taken.
28 if(!p_getc(&tempbyte,f))
6081 {
6082 return qe_invalid;
6083 }
6084 28 }
6085 4 }
6086
6087
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
16 if((Header->zelda_version == 0x192)&&(Header->build>145))
6088 {
6089 for(int32_t i=0; i<256; i++)
6090 {
6091 if(!p_getc(&tempbyte,f))
6092 {
6093 return qe_invalid;
6094 }
6095 }
6096 }
6097
6098
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(s_version>1)
6099 {
6100 if(!p_getc(&temp_misc.colors.subscr_shadow,f))
6101 {
6102 return qe_invalid;
6103 }
6104 }
6105
6106 //save game icons
6107
2/4
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
16 if((Header->zelda_version < 0x192)||
6108
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 ((Header->zelda_version == 0x192)&&(Header->build<73)))
6109 {
6110 4 icons=3;
6111 4 }
6112
6113
2/2
✓ Branch 0 taken 60 times.
✓ Branch 1 taken 16 times.
76 for(int32_t i=0; i<icons; i++)
6114 {
6115
1/2
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
60 if(!p_igetw(&temp_misc.icons[i],f))
6116 {
6117 return qe_invalid;
6118 }
6119 60 }
6120 16 }
6121
6122
2/4
✓ Branch 0 taken 124 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
128 if((Header->zelda_version < 0x192)||
6123
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 124 times.
124 ((Header->zelda_version == 0x192)&&(Header->build<30)))
6124 {
6125 4 memcpy(Misc, &temp_misc, sizeof(temp_misc));
6126
6127 4 return 0;
6128 }
6129
6130 //pond information
6131
1/2
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
124 if(Header->zelda_version < 0x193)
6132 {
6133 if((Header->zelda_version == 0x192)&&(Header->build<146))
6134 {
6135 pondsize=25;
6136 }
6137
6138 for(int32_t i=0; i<ponds; i++)
6139 {
6140 for(int32_t j=0; j<pondsize; j++)
6141 {
6142 if(!p_getc(&tempbyte,f))
6143 {
6144 return qe_invalid;
6145
6146 }
6147 }
6148 }
6149 }
6150
6151 //end string
6152
1/4
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
124 if((Header->zelda_version < 0x192)||
6153
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 124 times.
124 ((Header->zelda_version == 0x192)&&(Header->build<146)))
6154 {
6155 if(!p_getc(&tempbyte,f))
6156 {
6157 return qe_invalid;
6158 }
6159
6160 temp_misc.endstring=tempbyte;
6161
6162 if(!p_getc(&tempbyte,f))
6163 {
6164 return qe_invalid;
6165 }
6166 }
6167 else
6168 {
6169
1/2
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
124 if(!p_igetw(&temp_misc.endstring,f))
6170 {
6171 return qe_invalid;
6172 }
6173 }
6174
6175 //expansion
6176
1/2
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
124 if(Header->zelda_version < 0x193)
6177 {
6178 if((Header->zelda_version == 0x192)&&(Header->build<73))
6179 {
6180 expansionsize=99*2;
6181 }
6182
6183 for(int32_t i=0; i<expansionsize; i++)
6184 {
6185 if(!p_getc(&tempbyte,f))
6186 {
6187 return qe_invalid;
6188 }
6189 }
6190 }
6191 //shops v8
6192
6193
6194
2/2
✓ Branch 0 taken 89 times.
✓ Branch 1 taken 35 times.
124 if(s_version >= 8)
6195 {
6196
2/2
✓ Branch 0 taken 512 times.
✓ Branch 1 taken 35 times.
547 for(int32_t i=0; i<shops; i++)
6197 {
6198
2/2
✓ Branch 0 taken 1536 times.
✓ Branch 1 taken 512 times.
2048 for(int32_t j=0; j<3; j++)
6199 {
6200
1/2
✓ Branch 0 taken 1536 times.
✗ Branch 1 not taken.
1536 if(!p_igetw(&temp_misc.shop[i].str[j],f))
6201 return qe_invalid;
6202 1536 }
6203 512 }
6204 35 }
6205
6206 124 memset(&temp_misc.questmisc, 0, sizeof(int32_t)*32);
6207 124 memset(&temp_misc.questmisc_strings, 0, sizeof(char)*4096);
6208 124 memset(&temp_misc.zscript_last_compiled_version, 0, sizeof(int32_t));
6209
6210 //v9 includes quest misc[32]
6211
2/2
✓ Branch 0 taken 89 times.
✓ Branch 1 taken 35 times.
124 if(s_version >= 9)
6212 {
6213
2/2
✓ Branch 0 taken 1120 times.
✓ Branch 1 taken 35 times.
1155 for ( int32_t q = 0; q < 32; q++ )
6214 {
6215
1/2
✓ Branch 0 taken 1120 times.
✗ Branch 1 not taken.
1120 if(!p_igetl(&temp_misc.questmisc[q],f))
6216 return qe_invalid;
6217 1120 }
6218
2/2
✓ Branch 0 taken 1120 times.
✓ Branch 1 taken 35 times.
1155 for ( int32_t q = 0; q < 32; q++ )
6219 {
6220
2/2
✓ Branch 0 taken 143360 times.
✓ Branch 1 taken 1120 times.
144480 for ( int32_t j = 0; j < 128; j++ )
6221
1/2
✓ Branch 0 taken 143360 times.
✗ Branch 1 not taken.
143360 if(!p_getc(&temp_misc.questmisc_strings[q][j],f))
6222 return qe_invalid;
6223 1120 }
6224 35 }
6225
6226
2/2
✓ Branch 0 taken 35 times.
✓ Branch 1 taken 89 times.
124 if(s_version >= 11 )
6227 {
6228
1/2
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
35 if(!p_igetl(&temp_misc.zscript_last_compiled_version,f))
6229 return qe_invalid;
6230 35 }
6231
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 89 times.
89 else if(s_version < 11 )
6232 {
6233 89 temp_misc.zscript_last_compiled_version = -1;
6234 89 }
6235
6236 124 FFCore.quest_format[vLastCompile] = temp_misc.zscript_last_compiled_version;
6237
6238
2/2
✓ Branch 0 taken 35 times.
✓ Branch 1 taken 89 times.
124 if(s_version >= 12)
6239 {
6240 byte spr;
6241
2/2
✓ Branch 0 taken 8960 times.
✓ Branch 1 taken 35 times.
8995 for(int32_t q = 0; q < sprMAX; ++q)
6242 {
6243
1/2
✓ Branch 0 taken 8960 times.
✗ Branch 1 not taken.
8960 if(!p_getc(&spr,f))
6244 return qe_invalid;
6245 8960 temp_misc.sprites[q] = spr;
6246 8960 }
6247 35 }
6248 else
6249 {
6250 89 memset(&(temp_misc.sprites), 0, sizeof(temp_misc.sprites));
6251 //temp_misc.sprites[sprFALL] = ;
6252 }
6253
6254
2/2
✓ Branch 0 taken 35 times.
✓ Branch 1 taken 89 times.
124 if(s_version >= 13)
6255 {
6256
2/2
✓ Branch 0 taken 2240 times.
✓ Branch 1 taken 35 times.
2275 for(size_t q = 0; q < 64; ++q)
6257 {
6258 2240 bottletype* bt = &(temp_misc.bottle_types[q]);
6259
1/2
✓ Branch 0 taken 2240 times.
✗ Branch 1 not taken.
2240 if (!p_getstr(bt->name, sizeof(bt->name)-1, f))
6260 return qe_invalid;
6261
2/2
✓ Branch 0 taken 6720 times.
✓ Branch 1 taken 2240 times.
8960 for(size_t j = 0; j < 3; ++j)
6262 {
6263
1/2
✓ Branch 0 taken 6720 times.
✗ Branch 1 not taken.
6720 if (!p_getc(&(bt->counter[j]), f))
6264 return qe_invalid;
6265
1/2
✓ Branch 0 taken 6720 times.
✗ Branch 1 not taken.
6720 if (!p_igetw(&(bt->amount[j]), f))
6266 return qe_invalid;
6267 6720 }
6268
1/2
✓ Branch 0 taken 2240 times.
✗ Branch 1 not taken.
2240 if (!p_getc(&(bt->flags), f))
6269 return qe_invalid;
6270
1/2
✓ Branch 0 taken 2240 times.
✗ Branch 1 not taken.
2240 if (!p_getc(&(bt->next_type), f))
6271 return qe_invalid;
6272 2240 }
6273
2/2
✓ Branch 0 taken 8960 times.
✓ Branch 1 taken 35 times.
8995 for(size_t q = 0; q < 256; ++q)
6274 {
6275 8960 bottleshoptype* bst = &(temp_misc.bottle_shop_types[q]);
6276
1/2
✓ Branch 0 taken 8960 times.
✗ Branch 1 not taken.
8960 if (!pfread(bst->name, sizeof(bst->name)-1, f))
6277 return qe_invalid;
6278
2/2
✓ Branch 0 taken 26880 times.
✓ Branch 1 taken 8960 times.
35840 for(size_t j = 0; j < 3; ++j)
6279 {
6280
1/2
✓ Branch 0 taken 26880 times.
✗ Branch 1 not taken.
26880 if (!p_getc(&(bst->fill[j]), f))
6281 return qe_invalid;
6282
1/2
✓ Branch 0 taken 26880 times.
✗ Branch 1 not taken.
26880 if (!p_igetw(&(bst->comb[j]), f))
6283 return qe_invalid;
6284
1/2
✓ Branch 0 taken 26880 times.
✗ Branch 1 not taken.
26880 if (!p_getc(&(bst->cset[j]), f))
6285 return qe_invalid;
6286
1/2
✓ Branch 0 taken 26880 times.
✗ Branch 1 not taken.
26880 if (!p_igetw(&(bst->price[j]), f))
6287 return qe_invalid;
6288
1/2
✓ Branch 0 taken 26880 times.
✗ Branch 1 not taken.
26880 if (!p_igetw(&(bst->str[j]), f))
6289 return qe_invalid;
6290 26880 }
6291 8960 }
6292 35 }
6293 else
6294 {
6295
2/2
✓ Branch 0 taken 5696 times.
✓ Branch 1 taken 89 times.
5785 for(size_t q = 0; q < 64; ++q)
6296 5696 temp_misc.bottle_types[q].clear();
6297
2/2
✓ Branch 0 taken 22784 times.
✓ Branch 1 taken 89 times.
22873 for(size_t q = 0; q < 256; ++q)
6298 22784 temp_misc.bottle_shop_types[q].clear();
6299 }
6300
6301
2/2
✓ Branch 0 taken 35 times.
✓ Branch 1 taken 89 times.
124 if(s_version >= 14)
6302 {
6303 byte msfx;
6304
2/2
✓ Branch 0 taken 8960 times.
✓ Branch 1 taken 35 times.
8995 for(int32_t q = 0; q < sfxMAX; ++q)
6305 {
6306
1/2
✓ Branch 0 taken 8960 times.
✗ Branch 1 not taken.
8960 if(!p_getc(&msfx,f))
6307 return qe_invalid;
6308 8960 temp_misc.miscsfx[q] = msfx;
6309 8960 }
6310 35 }
6311 else
6312 {
6313 89 memset(&(temp_misc.miscsfx), 0, sizeof(temp_misc.miscsfx));
6314 89 temp_misc.miscsfx[sfxBUSHGRASS] = WAV_ZN1GRASSCUT;
6315 89 temp_misc.miscsfx[sfxLOWHEART] = WAV_ER;
6316 }
6317
2/2
✓ Branch 0 taken 35 times.
✓ Branch 1 taken 89 times.
124 if(s_version < 15)
6318 {
6319 89 temp_misc.miscsfx[sfxHURTPLAYER] = WAV_OUCH;
6320 89 temp_misc.miscsfx[sfxHAMMERPOUND] = WAV_ZN1HAMMERPOST;
6321 89 temp_misc.miscsfx[sfxSUBSCR_ITEM_ASSIGN] = WAV_PLACE;
6322 89 temp_misc.miscsfx[sfxSUBSCR_CURSOR_MOVE] = WAV_CHIME;
6323 89 temp_misc.miscsfx[sfxREFILL] = WAV_MSG;
6324 89 temp_misc.miscsfx[sfxDRAIN] = WAV_MSG;
6325 89 }
6326
6327
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 124 times.
124 if (!should_skip)
6328 124 memcpy(Misc, &temp_misc, sizeof(temp_misc));
6329
6330 124 return 0;
6331 128 }
6332
6333 extern char *item_string[MAXITEMS];
6334 extern const char *old_item_string[iLast];
6335 extern char *weapon_string[MAXWPNS];
6336 extern const char *old_weapon_string[wLast];
6337
6338 128 int32_t readitems(PACKFILE *f, word version, word build)
6339 {
6340
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 124 times.
128 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_items);
6341
6342 byte padding;
6343 int32_t dummy;
6344 128 word items_to_read=MAXITEMS;
6345 itemdata tempitem;
6346 128 word s_version=0, s_cversion=0;
6347 word dummy_word;
6348
6349
1/2
✓ Branch 0 taken 128 times.
✗ Branch 1 not taken.
128 if(version < 0x186)
6350 {
6351 items_to_read=64;
6352 }
6353
6354
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 124 times.
128 if(version > 0x192)
6355 {
6356 124 items_to_read=0;
6357
6358 //section version info
6359
1/2
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
124 if(!p_igetw(&s_version,f))
6360 {
6361 return qe_invalid;
6362 }
6363
6364 124 FFCore.quest_format[vItems] = s_version;
6365
6366 //al_trace("Items version %d\n", s_version);
6367
1/2
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
124 if(!p_igetw(&s_cversion,f))
6368 {
6369 return qe_invalid;
6370 }
6371
6372 //section size
6373
1/2
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
124 if(!p_igetl(&dummy,f))
6374 {
6375 return qe_invalid;
6376 }
6377
6378 //finally... section data
6379
1/2
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
124 if(!p_igetw(&items_to_read,f))
6380 {
6381 return qe_invalid;
6382 }
6383
6384
2/4
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 124 times.
124 if (!(items_to_read >= 0 && items_to_read <= MAXITEMS))
6385 {
6386 return qe_invalid;
6387 }
6388 124 }
6389
6390
2/2
✓ Branch 0 taken 112 times.
✓ Branch 1 taken 16 times.
128 if(s_version>1)
6391 {
6392
2/2
✓ Branch 0 taken 28672 times.
✓ Branch 1 taken 112 times.
28784 for(int32_t i=0; i<items_to_read; i++)
6393 {
6394 char tempname[64];
6395
6396
1/2
✓ Branch 0 taken 28672 times.
✗ Branch 1 not taken.
28672 if(!pfread(tempname, 64, f))
6397 {
6398 return qe_invalid;
6399 }
6400
6401 28672 item_string[i][0] = '\0';
6402 28672 strncat(item_string[i], tempname, 64 - 1);
6403 28672 }
6404 112 }
6405
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 else if (!should_skip)
6406 {
6407
2/2
✓ Branch 0 taken 4096 times.
✓ Branch 1 taken 16 times.
4112 for(int32_t i=0; i<MAXITEMS; i++)
6408 {
6409 4096 reset_itemname(i);
6410 4096 }
6411 16 }
6412
6413
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 128 times.
128 if (!should_skip)
6414
2/2
✓ Branch 0 taken 32768 times.
✓ Branch 1 taken 128 times.
32896 for(int32_t i=0; i<MAXITEMS; i++)
6415 {
6416 32768 itemdata& id = itemsbuf[i];
6417 32768 memset(&id, 0, sizeof(itemdata));
6418 32768 id.count=-1;
6419 32768 id.playsound=WAV_SCALE;
6420 32768 reset_itembuf(&id,i);
6421 32896 }
6422
6423
2/2
✓ Branch 0 taken 30536 times.
✓ Branch 1 taken 128 times.
30664 for(int32_t i=0; i<items_to_read; i++)
6424 {
6425 30536 memset(&tempitem, 0, sizeof(itemdata));
6426 30536 reset_itembuf(&tempitem,i);
6427
6428
6429
2/2
✓ Branch 0 taken 8960 times.
✓ Branch 1 taken 21576 times.
30536 if ( s_version > 35 ) //expanded tiles
6430 {
6431
1/2
✓ Branch 0 taken 8960 times.
✗ Branch 1 not taken.
8960 if(!p_igetl(&tempitem.tile,f))
6432 {
6433 return qe_invalid;
6434 }
6435 8960 }
6436 else
6437 {
6438
1/2
✓ Branch 0 taken 21576 times.
✗ Branch 1 not taken.
21576 if(!p_igetw(&tempitem.tile,f))
6439 {
6440 return qe_invalid;
6441 }
6442 }
6443
6444
1/2
✓ Branch 0 taken 30536 times.
✗ Branch 1 not taken.
30536 if(!p_getc(&tempitem.misc_flags,f))
6445 {
6446 return qe_invalid;
6447 }
6448
6449
1/2
✓ Branch 0 taken 30536 times.
✗ Branch 1 not taken.
30536 if(!p_getc(&tempitem.csets,f))
6450 {
6451 return qe_invalid;
6452 }
6453
6454
1/2
✓ Branch 0 taken 30536 times.
✗ Branch 1 not taken.
30536 if(!p_getc(&tempitem.frames,f))
6455 {
6456 return qe_invalid;
6457 }
6458
6459
1/2
✓ Branch 0 taken 30536 times.
✗ Branch 1 not taken.
30536 if(!p_getc(&tempitem.speed,f))
6460 {
6461 return qe_invalid;
6462 }
6463
6464
1/2
✓ Branch 0 taken 30536 times.
✗ Branch 1 not taken.
30536 if(!p_getc(&tempitem.delay,f))
6465 {
6466 return qe_invalid;
6467 }
6468
6469
2/2
✓ Branch 0 taken 29512 times.
✓ Branch 1 taken 1024 times.
30536 if(version < 0x193)
6470 {
6471
1/2
✓ Branch 0 taken 1024 times.
✗ Branch 1 not taken.
1024 if(!p_getc(&padding,f))
6472 {
6473 return qe_invalid;
6474 }
6475
6476
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 1024 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1024 if((version < 0x192)||((version == 0x192)&&(build<186)))
6477 {
6478
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1024 times.
1024 if (should_skip)
6479 continue;
6480
6481
3/3
✓ Branch 0 taken 1016 times.
✓ Branch 1 taken 4 times.
✓ Branch 2 taken 4 times.
1024 switch(i)
6482 {
6483 case iShield:
6484 4 tempitem.ltm=get_qr(qr_BSZELDA)?-12:10;
6485 4 break;
6486
6487 case iMShield:
6488 4 tempitem.ltm=get_qr(qr_BSZELDA)?-6:-10;
6489 4 break;
6490
6491 default:
6492 1016 tempitem.ltm=0;
6493 1016 break;
6494 }
6495
6496 1024 tempitem.count=-1;
6497 1024 tempitem.flags=tempitem.wpn=tempitem.wpn2=tempitem.wpn3=tempitem.wpn3=tempitem.pickup_hearts=
6498 1024 tempitem.misc1=tempitem.misc2=tempitem.usesound=0;
6499 1024 tempitem.family=0xFF;
6500 1024 tempitem.playsound=WAV_SCALE;
6501 1024 reset_itembuf(&tempitem,i);
6502
6503 1024 memcpy(&itemsbuf[i], &tempitem, sizeof(itemdata));
6504
6505 1024 continue;
6506 }
6507 }
6508
6509
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 29512 times.
29512 if(!p_igetl(&tempitem.ltm,f))
6510 {
6511 return qe_invalid;
6512 }
6513
6514
1/2
✓ Branch 0 taken 29512 times.
✗ Branch 1 not taken.
29512 if(version < 0x193)
6515 {
6516 for(int32_t q=0; q<12; q++)
6517 {
6518 if(!p_getc(&padding,f))
6519 {
6520 return qe_invalid;
6521 }
6522 }
6523 }
6524
6525
2/2
✓ Branch 0 taken 28672 times.
✓ Branch 1 taken 840 times.
29512 if(s_version>1)
6526 {
6527
2/2
✓ Branch 0 taken 8960 times.
✓ Branch 1 taken 19712 times.
28672 if ( s_version >= 31 )
6528 {
6529
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8960 times.
8960 if(!p_igetl(&tempitem.family,f))
6530 {
6531 return qe_invalid;
6532 }
6533 8960 }
6534 else
6535 {
6536
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 19712 times.
19712 if(!p_getc(&tempitem.family,f))
6537 {
6538 return qe_invalid;
6539 }
6540 }
6541
1/2
✓ Branch 0 taken 28672 times.
✗ Branch 1 not taken.
28672 if(s_version < 16)
6542 if(tempitem.family == 0xFF)
6543 tempitem.family = itype_misc;
6544
6545
1/2
✓ Branch 0 taken 28672 times.
✗ Branch 1 not taken.
28672 if(!p_getc(&tempitem.fam_type,f))
6546 {
6547 return qe_invalid;
6548 }
6549
6550
1/2
✓ Branch 0 taken 28672 times.
✗ Branch 1 not taken.
28672 if(s_version>5)
6551 {
6552
2/2
✓ Branch 0 taken 8960 times.
✓ Branch 1 taken 19712 times.
28672 if(s_version>=31)
6553 {
6554
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8960 times.
8960 if(!p_igetl(&tempitem.power,f))
6555 {
6556 return qe_invalid;
6557 }
6558 8960 }
6559 else
6560 {
6561
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 19712 times.
19712 if(!p_getc(&tempitem.power,f))
6562 {
6563 return qe_invalid;
6564 }
6565 }
6566
6567 //converted flags from 16b to 32b -Z
6568
2/2
✓ Branch 0 taken 19712 times.
✓ Branch 1 taken 8960 times.
28672 if ( s_version < 41 )
6569 {
6570
1/2
✓ Branch 0 taken 19712 times.
✗ Branch 1 not taken.
19712 if(!p_igetw(&tempitem.flags,f))
6571 {
6572 return qe_invalid;
6573 }
6574 19712 }
6575 else
6576 {
6577
1/2
✓ Branch 0 taken 8960 times.
✗ Branch 1 not taken.
8960 if(!p_igetl(&tempitem.flags,f))
6578 {
6579 return qe_invalid;
6580 }
6581 }
6582 28672 }
6583 else
6584 {
6585 //tempitem.power = tempitem.fam_type;
6586 char tempchar;
6587
6588 if(!p_getc(&tempchar,f))
6589 {
6590 return qe_invalid;
6591 }
6592
6593 tempitem.flags |= (tempchar ? ITEM_GAMEDATA : 0);
6594 }
6595
6596
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 28672 times.
28672 if(!p_igetw(&tempitem.script,f))
6597 {
6598 return qe_invalid;
6599 }
6600
6601
1/2
✓ Branch 0 taken 28672 times.
✗ Branch 1 not taken.
28672 if(s_version<=3)
6602 {
6603 if(tempitem.script > NUMSCRIPTITEM)
6604 {
6605 tempitem.script = 0;
6606 }
6607 }
6608
6609
1/2
✓ Branch 0 taken 28672 times.
✗ Branch 1 not taken.
28672 if(!p_getc(&tempitem.count,f))
6610 {
6611 return qe_invalid;
6612 }
6613
6614
1/2
✓ Branch 0 taken 28672 times.
✗ Branch 1 not taken.
28672 if(!p_igetw(&tempitem.amount,f))
6615 {
6616 return qe_invalid;
6617 }
6618
6619
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 28672 times.
28672 if(!p_igetw(&tempitem.collect_script,f))
6620 {
6621 return qe_invalid;
6622 }
6623
6624
1/2
✓ Branch 0 taken 28672 times.
✗ Branch 1 not taken.
28672 if(s_version<=3)
6625 {
6626 if(tempitem.collect_script > NUMSCRIPTITEM)
6627 {
6628 tempitem.collect_script = 0;
6629 }
6630 }
6631
6632
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 28672 times.
28672 if(!p_igetw(&tempitem.setmax,f))
6633 {
6634 return qe_invalid;
6635 }
6636
6637
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 28672 times.
28672 if(!p_igetw(&tempitem.max,f))
6638 {
6639 return qe_invalid;
6640 }
6641
6642
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 28672 times.
28672 if(!p_getc(&tempitem.playsound,f))
6643 {
6644 return qe_invalid;
6645 }
6646
6647
2/2
✓ Branch 0 taken 229376 times.
✓ Branch 1 taken 28672 times.
258048 for(int32_t j=0; j<8; j++)
6648 {
6649
1/2
✓ Branch 0 taken 229376 times.
✗ Branch 1 not taken.
229376 if(!p_igetl(&tempitem.initiald[j],f))
6650 {
6651 return qe_invalid;
6652 }
6653 229376 }
6654
6655
2/2
✓ Branch 0 taken 57344 times.
✓ Branch 1 taken 28672 times.
86016 for(int32_t j=0; j<2; j++)
6656 {
6657
1/2
✓ Branch 0 taken 57344 times.
✗ Branch 1 not taken.
57344 if(!p_getc(&tempitem.initiala[j],f))
6658 {
6659 return qe_invalid;
6660 }
6661 57344 }
6662
6663
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 28672 times.
28672 if(s_version>4)
6664 {
6665
1/2
✓ Branch 0 taken 28672 times.
✗ Branch 1 not taken.
28672 if(s_version>5)
6666 {
6667
1/2
✓ Branch 0 taken 28672 times.
✗ Branch 1 not taken.
28672 if(!p_getc(&tempitem.wpn,f))
6668 {
6669 return qe_invalid;
6670 }
6671
6672
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 28672 times.
28672 if(!p_getc(&tempitem.wpn2,f))
6673 {
6674 return qe_invalid;
6675 }
6676
6677
1/2
✓ Branch 0 taken 28672 times.
✗ Branch 1 not taken.
28672 if(!p_getc(&tempitem.wpn3,f))
6678 {
6679 return qe_invalid;
6680 }
6681
6682
1/2
✓ Branch 0 taken 28672 times.
✗ Branch 1 not taken.
28672 if(!p_getc(&tempitem.wpn4,f))
6683 {
6684 return qe_invalid;
6685 }
6686
6687
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 28672 times.
28672 if(s_version>=15)
6688 {
6689
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 28672 times.
28672 if(!p_getc(&tempitem.wpn5,f))
6690 {
6691 return qe_invalid;
6692 }
6693
6694
1/2
✓ Branch 0 taken 28672 times.
✗ Branch 1 not taken.
28672 if(!p_getc(&tempitem.wpn6,f))
6695 {
6696 return qe_invalid;
6697 }
6698
6699
1/2
✓ Branch 0 taken 28672 times.
✗ Branch 1 not taken.
28672 if(!p_getc(&tempitem.wpn7,f))
6700 {
6701 return qe_invalid;
6702 }
6703
6704
1/2
✓ Branch 0 taken 28672 times.
✗ Branch 1 not taken.
28672 if(!p_getc(&tempitem.wpn8,f))
6705 {
6706 return qe_invalid;
6707 }
6708
6709
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 28672 times.
28672 if(!p_getc(&tempitem.wpn9,f))
6710 {
6711 return qe_invalid;
6712 }
6713
6714
1/2
✓ Branch 0 taken 28672 times.
✗ Branch 1 not taken.
28672 if(!p_getc(&tempitem.wpn10,f))
6715 {
6716 return qe_invalid;
6717 }
6718 28672 }
6719
6720
1/2
✓ Branch 0 taken 28672 times.
✗ Branch 1 not taken.
28672 if(!p_getc(&tempitem.pickup_hearts,f))
6721 {
6722 return qe_invalid;
6723 }
6724
6725
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 28672 times.
28672 if(s_version<15)
6726 {
6727 if(!p_igetw(&dummy_word,f))
6728 {
6729 return qe_invalid;
6730 }
6731
6732 tempitem.misc1=dummy_word;
6733
6734 if(!p_igetw(&dummy_word,f))
6735 {
6736 return qe_invalid;
6737 }
6738
6739 tempitem.misc2=dummy_word;
6740 }
6741 else
6742 {
6743
1/2
✓ Branch 0 taken 28672 times.
✗ Branch 1 not taken.
28672 if(!p_igetl(&tempitem.misc1,f))
6744 {
6745 return qe_invalid;
6746 }
6747
6748
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 28672 times.
28672 if(!p_igetl(&tempitem.misc2,f))
6749 {
6750 return qe_invalid;
6751 }
6752
6753 // Version 24: shICE -> shSCRIPT; previously, all shields could block script weapons
6754
1/2
✓ Branch 0 taken 28672 times.
✗ Branch 1 not taken.
28672 if(s_version<24)
6755 {
6756 if(tempitem.family==itype_shield)
6757 {
6758 tempitem.misc1|=shSCRIPT;
6759 }
6760 }
6761 }
6762
6763
2/2
✓ Branch 0 taken 19712 times.
✓ Branch 1 taken 8960 times.
28672 if(s_version < 53)
6764 {
6765 byte tempbyte;
6766
1/2
✓ Branch 0 taken 19712 times.
✗ Branch 1 not taken.
19712 if(!p_getc(&tempbyte,f))
6767 {
6768 return qe_invalid;
6769 }
6770 19712 tempitem.cost_amount[0] = tempbyte;
6771 19712 }
6772 else
6773 {
6774
2/2
✓ Branch 0 taken 17920 times.
✓ Branch 1 taken 8960 times.
26880 for(auto q = 0; q < 2; ++q)
6775 {
6776
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17920 times.
17920 if(!p_igetw(&tempitem.cost_amount[q],f))
6777 {
6778 return qe_invalid;
6779 }
6780 17920 }
6781 }
6782 28672 }
6783 else
6784 {
6785 char tempchar;
6786
6787 if(!p_getc(&tempchar,f))
6788 {
6789 return qe_invalid;
6790 }
6791
6792 tempitem.flags |= (tempchar ? ITEM_EDIBLE : 0);
6793 }
6794
6795 // June 2007: more misc. attributes
6796
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 28672 times.
28672 if(s_version>=12)
6797 {
6798
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 28672 times.
28672 if(s_version<15)
6799 {
6800 if(!p_igetw(&dummy_word,f))
6801 {
6802 return qe_invalid;
6803 }
6804
6805 tempitem.misc3=dummy_word;
6806
6807 if(!p_igetw(&dummy_word,f))
6808 {
6809 return qe_invalid;
6810 }
6811
6812 tempitem.misc4=dummy_word;
6813 }
6814 else
6815 {
6816
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 28672 times.
28672 if(!p_igetl(&tempitem.misc3,f))
6817 {
6818 return qe_invalid;
6819 }
6820
6821
1/2
✓ Branch 0 taken 28672 times.
✗ Branch 1 not taken.
28672 if(!p_igetl(&tempitem.misc4,f))
6822 {
6823 return qe_invalid;
6824 }
6825
6826
1/2
✓ Branch 0 taken 28672 times.
✗ Branch 1 not taken.
28672 if(!p_igetl(&tempitem.misc5,f))
6827 {
6828 return qe_invalid;
6829 }
6830
6831
1/2
✓ Branch 0 taken 28672 times.
✗ Branch 1 not taken.
28672 if(!p_igetl(&tempitem.misc6,f))
6832 {
6833 return qe_invalid;
6834 }
6835
6836
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 28672 times.
28672 if(!p_igetl(&tempitem.misc7,f))
6837 {
6838 return qe_invalid;
6839 }
6840
6841
1/2
✓ Branch 0 taken 28672 times.
✗ Branch 1 not taken.
28672 if(!p_igetl(&tempitem.misc8,f))
6842 {
6843 return qe_invalid;
6844 }
6845
6846
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 28672 times.
28672 if(!p_igetl(&tempitem.misc9,f))
6847 {
6848 return qe_invalid;
6849 }
6850
6851
1/2
✓ Branch 0 taken 28672 times.
✗ Branch 1 not taken.
28672 if(!p_igetl(&tempitem.misc10,f))
6852 {
6853 return qe_invalid;
6854 }
6855 }
6856
6857
1/2
✓ Branch 0 taken 28672 times.
✗ Branch 1 not taken.
28672 if(!p_getc(&tempitem.usesound,f))
6858 {
6859 return qe_invalid;
6860 }
6861
6862
2/2
✓ Branch 0 taken 8960 times.
✓ Branch 1 taken 19712 times.
28672 if(s_version >= 49)
6863 {
6864
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8960 times.
8960 if(!p_getc(&tempitem.usesound2,f))
6865 {
6866 return qe_invalid;
6867 }
6868 8960 }
6869 19712 else tempitem.usesound2 = 0;
6870
6871
3/4
✓ Branch 0 taken 19712 times.
✓ Branch 1 taken 8960 times.
✓ Branch 2 taken 19712 times.
✗ Branch 3 not taken.
28672 if(s_version < 50 && tempitem.family == itype_mirror)
6872 {
6873 //Split continue/dmap warp effect/sfx, port for old
6874 tempitem.misc2 = tempitem.misc1;
6875 tempitem.usesound2 = tempitem.usesound;
6876 }
6877 28672 }
6878 28672 }
6879
6880
2/2
✓ Branch 0 taken 19712 times.
✓ Branch 1 taken 8960 times.
28672 if ( s_version >= 26 ) //! New itemdata vars for weapon editor. -Z
6881 { // temp.useweapon, temp.usedefence, temp.weaprange, temp.weap_pattern[ITEM_MOVEMENT_PATTERNS]
6882
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8960 times.
8960 if(!p_getc(&tempitem.useweapon,f))
6883 {
6884 return qe_invalid;
6885 }
6886
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8960 times.
8960 if(!p_getc(&tempitem.usedefence,f))
6887 {
6888 return qe_invalid;
6889 }
6890
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8960 times.
8960 if(!p_igetl(&tempitem.weaprange,f))
6891 {
6892 return qe_invalid;
6893 }
6894
1/2
✓ Branch 0 taken 8960 times.
✗ Branch 1 not taken.
8960 if(!p_igetl(&tempitem.weapduration,f))
6895 {
6896 return qe_invalid;
6897 }
6898
2/2
✓ Branch 0 taken 89600 times.
✓ Branch 1 taken 8960 times.
98560 for ( int32_t q = 0; q < ITEM_MOVEMENT_PATTERNS; q++ )
6899 {
6900
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 89600 times.
89600 if(!p_igetl(&tempitem.weap_pattern[q],f))
6901 {
6902 return qe_invalid;
6903 }
6904 89600 }
6905 8960 }
6906
6907
2/2
✓ Branch 0 taken 19712 times.
✓ Branch 1 taken 8960 times.
28672 if ( s_version >= 27 ) //! New itemdata vars for weapon editor. -Z
6908 { // temp.useweapon, temp.usedefence, temp.weaprange, temp.weap_pattern[ITEM_MOVEMENT_PATTERNS]
6909
1/2
✓ Branch 0 taken 8960 times.
✗ Branch 1 not taken.
8960 if(!p_igetl(&tempitem.duplicates,f))
6910 {
6911 return qe_invalid;
6912 }
6913
2/2
✓ Branch 0 taken 71680 times.
✓ Branch 1 taken 8960 times.
80640 for ( int32_t q = 0; q < INITIAL_D; q++ )
6914 {
6915
1/2
✓ Branch 0 taken 71680 times.
✗ Branch 1 not taken.
71680 if(!p_igetl(&tempitem.weap_initiald[q],f))
6916 {
6917 return qe_invalid;
6918 }
6919 71680 }
6920
2/2
✓ Branch 0 taken 17920 times.
✓ Branch 1 taken 8960 times.
26880 for ( int32_t q = 0; q < INITIAL_A; q++ )
6921 {
6922
1/2
✓ Branch 0 taken 17920 times.
✗ Branch 1 not taken.
17920 if(!p_getc(&tempitem.weap_initiala[q],f))
6923 {
6924 return qe_invalid;
6925 }
6926 17920 }
6927
6928
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8960 times.
8960 if(!p_getc(&tempitem.drawlayer,f))
6929 {
6930 return qe_invalid;
6931 }
6932
6933
6934
1/2
✓ Branch 0 taken 8960 times.
✗ Branch 1 not taken.
8960 if(!p_igetl(&tempitem.hxofs,f))
6935 {
6936 return qe_invalid;
6937 }
6938
1/2
✓ Branch 0 taken 8960 times.
✗ Branch 1 not taken.
8960 if(!p_igetl(&tempitem.hyofs,f))
6939 {
6940 return qe_invalid;
6941 }
6942
1/2
✓ Branch 0 taken 8960 times.
✗ Branch 1 not taken.
8960 if(!p_igetl(&tempitem.hxsz,f))
6943 {
6944 return qe_invalid;
6945 }
6946
1/2
✓ Branch 0 taken 8960 times.
✗ Branch 1 not taken.
8960 if(!p_igetl(&tempitem.hysz,f))
6947 {
6948 return qe_invalid;
6949 }
6950
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8960 times.
8960 if(!p_igetl(&tempitem.hzsz,f))
6951 {
6952 return qe_invalid;
6953 }
6954
1/2
✓ Branch 0 taken 8960 times.
✗ Branch 1 not taken.
8960 if(!p_igetl(&tempitem.xofs,f))
6955 {
6956 return qe_invalid;
6957 }
6958
1/2
✓ Branch 0 taken 8960 times.
✗ Branch 1 not taken.
8960 if(!p_igetl(&tempitem.yofs,f))
6959 {
6960 return qe_invalid;
6961 }
6962
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8960 times.
8960 if(!p_igetl(&tempitem.weap_hxofs,f))
6963 {
6964 return qe_invalid;
6965 }
6966
1/2
✓ Branch 0 taken 8960 times.
✗ Branch 1 not taken.
8960 if(!p_igetl(&tempitem.weap_hyofs,f))
6967 {
6968 return qe_invalid;
6969 }
6970
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8960 times.
8960 if(!p_igetl(&tempitem.weap_hxsz,f))
6971 {
6972 return qe_invalid;
6973 }
6974
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8960 times.
8960 if(!p_igetl(&tempitem.weap_hysz,f))
6975 {
6976 return qe_invalid;
6977 }
6978
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8960 times.
8960 if(!p_igetl(&tempitem.weap_hzsz,f))
6979 {
6980 return qe_invalid;
6981 }
6982
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8960 times.
8960 if(!p_igetl(&tempitem.weap_xofs,f))
6983 {
6984 return qe_invalid;
6985 }
6986
1/2
✓ Branch 0 taken 8960 times.
✗ Branch 1 not taken.
8960 if(!p_igetl(&tempitem.weap_yofs,f))
6987 {
6988 return qe_invalid;
6989 }
6990
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8960 times.
8960 if(!p_igetw(&tempitem.weaponscript,f))
6991 {
6992 return qe_invalid;
6993 }
6994
1/2
✓ Branch 0 taken 8960 times.
✗ Branch 1 not taken.
8960 if(!p_igetl(&tempitem.wpnsprite,f))
6995 {
6996 return qe_invalid;
6997 }
6998 8960 auto num_cost_tmr = (s_version > 52 ? 2 : 1);
6999
2/2
✓ Branch 0 taken 17920 times.
✓ Branch 1 taken 8960 times.
26880 for(auto q = 0; q < num_cost_tmr; ++q)
7000 {
7001
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17920 times.
17920 if(!p_igetl(&tempitem.magiccosttimer[q],f))
7002 {
7003 return qe_invalid;
7004 }
7005 17920 }
7006
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8960 times.
8960 for(auto q = num_cost_tmr; q < 2; ++q)
7007 tempitem.magiccosttimer[q] = 0;
7008 8960 }
7009
2/2
✓ Branch 0 taken 19712 times.
✓ Branch 1 taken 8960 times.
28672 if ( s_version >= 28 ) //! New itemdata vars for weapon editor. -Z
7010 {
7011 //Item Size FLags, TileWidth, TileHeight
7012
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8960 times.
8960 if(!p_igetl(&tempitem.overrideFLAGS,f))
7013 {
7014 return qe_invalid;
7015 }
7016
1/2
✓ Branch 0 taken 8960 times.
✗ Branch 1 not taken.
8960 if(!p_igetl(&tempitem.tilew,f))
7017 {
7018 return qe_invalid;
7019 }
7020
1/2
✓ Branch 0 taken 8960 times.
✗ Branch 1 not taken.
8960 if(!p_igetl(&tempitem.tileh,f))
7021 {
7022 return qe_invalid;
7023 }
7024 8960 }
7025
2/2
✓ Branch 0 taken 19712 times.
✓ Branch 1 taken 8960 times.
28672 if ( s_version >= 29 ) //! More new vars.
7026 {
7027 //Item Size FLags, TileWidth, TileHeight
7028
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8960 times.
8960 if(!p_igetl(&tempitem.weapoverrideFLAGS,f))
7029 {
7030 return qe_invalid;
7031 }
7032
1/2
✓ Branch 0 taken 8960 times.
✗ Branch 1 not taken.
8960 if(!p_igetl(&tempitem.weap_tilew,f))
7033 {
7034 return qe_invalid;
7035 }
7036
1/2
✓ Branch 0 taken 8960 times.
✗ Branch 1 not taken.
8960 if(!p_igetl(&tempitem.weap_tileh,f))
7037 {
7038 return qe_invalid;
7039 }
7040 8960 }
7041
2/2
✓ Branch 0 taken 19712 times.
✓ Branch 1 taken 8960 times.
28672 if ( s_version >= 30 ) //! More new vars.
7042 {
7043 //Pickup Type
7044
1/2
✓ Branch 0 taken 8960 times.
✗ Branch 1 not taken.
8960 if(!p_igetl(&tempitem.pickup,f))
7045 {
7046 return qe_invalid;
7047 }
7048 8960 }
7049
2/2
✓ Branch 0 taken 19712 times.
✓ Branch 1 taken 8960 times.
28672 if ( s_version >= 32 ) //! More new vars.
7050 {
7051 //Pickup Type
7052
1/2
✓ Branch 0 taken 8960 times.
✗ Branch 1 not taken.
8960 if(!p_igetw(&tempitem.pstring,f))
7053 {
7054 return qe_invalid;
7055 }
7056 8960 }
7057
2/2
✓ Branch 0 taken 19712 times.
✓ Branch 1 taken 8960 times.
28672 if ( s_version >= 33 ) //! More new vars.
7058 {
7059 //Pickup Type
7060
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8960 times.
8960 if(!p_igetw(&tempitem.pickup_string_flags,f))
7061 {
7062 return qe_invalid;
7063 }
7064 8960 }
7065
2/2
✓ Branch 0 taken 19712 times.
✓ Branch 1 taken 8960 times.
28672 if ( s_version >= 34 ) //! cost counter
7066 {
7067
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8960 times.
8960 if(s_version < 53)
7068 {
7069 if(!p_getc(&tempitem.cost_counter[0],f))
7070 {
7071 return qe_invalid;
7072 }
7073 }
7074 else
7075 {
7076
2/2
✓ Branch 0 taken 17920 times.
✓ Branch 1 taken 8960 times.
26880 for(auto q = 0; q < 2; ++q)
7077 {
7078
1/2
✓ Branch 0 taken 17920 times.
✗ Branch 1 not taken.
17920 if(!p_getc(&tempitem.cost_counter[q],f))
7079 {
7080 return qe_invalid;
7081 }
7082 17920 }
7083 }
7084 8960 }
7085
2/2
✓ Branch 0 taken 19712 times.
✓ Branch 1 taken 8960 times.
28672 if ( s_version >= 44 ) //! sprite scripts
7086 {
7087
2/2
✓ Branch 0 taken 71680 times.
✓ Branch 1 taken 8960 times.
80640 for ( int32_t q = 0; q < 8; q++ )
7088 {
7089
2/2
✓ Branch 0 taken 4659200 times.
✓ Branch 1 taken 71680 times.
4730880 for ( int32_t w = 0; w < 65; w++ )
7090 {
7091
1/2
✓ Branch 0 taken 4659200 times.
✗ Branch 1 not taken.
4659200 if(!p_getc(&(tempitem.initD_label[q][w]),f))
7092 {
7093 return qe_invalid;
7094 }
7095 4659200 }
7096
2/2
✓ Branch 0 taken 4659200 times.
✓ Branch 1 taken 71680 times.
4730880 for ( int32_t w = 0; w < 65; w++ )
7097 {
7098
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4659200 times.
4659200 if(!p_getc(&(tempitem.weapon_initD_label[q][w]),f))
7099 {
7100 return qe_invalid;
7101 }
7102 4659200 }
7103
2/2
✓ Branch 0 taken 4659200 times.
✓ Branch 1 taken 71680 times.
4730880 for ( int32_t w = 0; w < 65; w++ )
7104 {
7105
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4659200 times.
4659200 if(!p_getc(&(tempitem.sprite_initD_label[q][w]),f))
7106 {
7107 return qe_invalid;
7108 }
7109 4659200 }
7110
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 71680 times.
71680 if(!p_igetl(&(tempitem.sprite_initiald[q]),f))
7111 {
7112 return qe_invalid;
7113 }
7114
7115 71680 }
7116
2/2
✓ Branch 0 taken 17920 times.
✓ Branch 1 taken 8960 times.
26880 for ( int32_t q = 0; q < 2; q++ )
7117 {
7118
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17920 times.
17920 if(!p_getc(&(tempitem.sprite_initiala[q]),f))
7119 {
7120 return qe_invalid;
7121 }
7122 17920 }
7123 //Pickup Type
7124
1/2
✓ Branch 0 taken 8960 times.
✗ Branch 1 not taken.
8960 if(!p_igetw(&tempitem.sprite_script,f))
7125 {
7126 return qe_invalid;
7127 }
7128 8960 }
7129
2/2
✓ Branch 0 taken 19712 times.
✓ Branch 1 taken 8960 times.
28672 if ( s_version >= 48 ) //! pickup flags
7130 {
7131
1/2
✓ Branch 0 taken 8960 times.
✗ Branch 1 not taken.
8960 if(!p_getc(&(tempitem.pickupflag),f))
7132 {
7133 return qe_invalid;
7134 }
7135 8960 }
7136
2/2
✓ Branch 0 taken 21248 times.
✓ Branch 1 taken 7424 times.
28672 if ( s_version >= 57 )
7137 {
7138 7424 std::string str;
7139
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 7424 times.
✓ Branch 2 taken 7424 times.
✗ Branch 3 not taken.
7424 if(!p_getcstr(&str,f))
7140 return qe_invalid;
7141 7424 strncpy(tempitem.display_name,str.c_str(),255);
7142
1/3
✓ Branch 0 taken 7424 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
7424 }
7143 28672 }
7144 else
7145 {
7146 840 tempitem.count=-1;
7147 840 tempitem.family=itype_misc;
7148 840 tempitem.flags=tempitem.wpn=tempitem.wpn2=tempitem.wpn3=tempitem.wpn3=tempitem.pickup_hearts=tempitem.misc1=tempitem.misc2=tempitem.usesound=0;
7149 840 tempitem.playsound=WAV_SCALE;
7150 840 reset_itembuf(&tempitem,i);
7151 }
7152
7153
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 29512 times.
29512 if (!should_skip)
7154 {
7155
1/2
✓ Branch 0 taken 29512 times.
✗ Branch 1 not taken.
29512 if(loading_tileset_flags & TILESET_CLEARSCRIPTS)
7156 {
7157 tempitem.script = 0;
7158 tempitem.weaponscript = 0;
7159 for(int q = 0; q < 8; ++q)
7160 {
7161 tempitem.initiald[q] = 0;
7162 tempitem.weap_initiald[q] = 0;
7163 }
7164 }
7165 29512 memcpy(&itemsbuf[i], &tempitem, sizeof(itemdata));
7166 29512 }
7167 29512 }
7168
7169
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 128 times.
128 if (should_skip)
7170 return 0;
7171
7172 //////////////////////////////////////////////////////
7173 // Now do any updates because of new item additions
7174 // (These can't be done above because items_to_read
7175 // might be too low.)
7176 //////////////////////////////////////////////////////
7177
2/2
✓ Branch 0 taken 32768 times.
✓ Branch 1 taken 128 times.
32896 for(int32_t i=0; i<MAXITEMS; i++)
7178 {
7179 32768 memcpy(&tempitem, &itemsbuf[i], sizeof(itemdata));
7180
7181 //Account for older quests that didn't have an actual item for the used letter
7182
4/4
✓ Branch 0 taken 4096 times.
✓ Branch 1 taken 28672 times.
✓ Branch 2 taken 4080 times.
✓ Branch 3 taken 16 times.
32768 if(s_version < 2 && i==iLetterUsed)
7183 {
7184 16 reset_itembuf(&tempitem, iLetterUsed);
7185 16 strcpy(item_string[i],old_item_string[i]);
7186 16 tempitem.tile = itemsbuf[iLetter].tile;
7187 16 tempitem.csets = itemsbuf[iLetter].csets;
7188 16 tempitem.misc_flags = itemsbuf[iLetter].misc_flags;
7189 16 tempitem.frames = itemsbuf[iLetter].frames;
7190 16 tempitem.speed = itemsbuf[iLetter].speed;
7191 16 tempitem.ltm = itemsbuf[iLetter].ltm;
7192 16 }
7193
7194
2/2
✓ Branch 0 taken 28672 times.
✓ Branch 1 taken 4096 times.
32768 if(s_version < 3)
7195 {
7196
3/3
✓ Branch 0 taken 352 times.
✓ Branch 1 taken 3728 times.
✓ Branch 2 taken 16 times.
4096 switch(i)
7197 {
7198 case iRocsFeather:
7199 case iHoverBoots:
7200 case iSpinScroll:
7201 case iL2SpinScroll:
7202 case iCrossScroll:
7203 case iQuakeScroll:
7204 case iL2QuakeScroll:
7205 case iWhispRing:
7206 case iL2WhispRing:
7207 case iChargeRing:
7208 case iL2ChargeRing:
7209 case iPerilScroll:
7210 case iWalletL3:
7211 case iQuiverL4:
7212 case iBombBagL4:
7213 case iBracelet:
7214 case iL2Bracelet:
7215 case iOldGlove:
7216 case iL2Ladder:
7217 case iWealthMedal:
7218 case iL2WealthMedal:
7219 case iL3WealthMedal:
7220 352 reset_itembuf(&tempitem, i);
7221 352 strcpy(item_string[i],old_item_string[i]);
7222 352 break;
7223
7224 case iSShield:
7225 16 reset_itembuf(&tempitem, i);
7226 16 strcpy(item_string[i],old_item_string[i]);
7227 16 strcpy(item_string[iShield],old_item_string[iShield]);
7228 16 strcpy(item_string[iMShield],old_item_string[iMShield]);
7229 16 break;
7230 }
7231 4096 }
7232
7233
2/2
✓ Branch 0 taken 28672 times.
✓ Branch 1 taken 4096 times.
32768 if(s_version < 5)
7234 {
7235
2/2
✓ Branch 0 taken 112 times.
✓ Branch 1 taken 3984 times.
4096 switch(i)
7236 {
7237 case iHeartRing:
7238 case iL2HeartRing:
7239 case iL3HeartRing:
7240 case iMagicRing:
7241 case iL2MagicRing:
7242 case iL3MagicRing:
7243 case iL4MagicRing:
7244 112 reset_itembuf(&tempitem, i);
7245 112 strcpy(item_string[i],old_item_string[i]);
7246 112 break;
7247 }
7248 4096 }
7249
7250
2/2
✓ Branch 0 taken 28672 times.
✓ Branch 1 taken 4096 times.
32768 if(s_version < 6) // April 2007: Advanced item editing capabilities.
7251 {
7252
4/4
✓ Branch 0 taken 4080 times.
✓ Branch 1 taken 16 times.
✓ Branch 2 taken 16 times.
✓ Branch 3 taken 4064 times.
4096 if(i!=iBPotion && i!=iRPotion)
7253 4064 tempitem.flags |= get_bit(deprecated_rules,32) ? ITEM_KEEPOLD : 0;
7254
7255
43/43
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 16 times.
✓ Branch 2 taken 16 times.
✓ Branch 3 taken 16 times.
✓ Branch 4 taken 16 times.
✓ Branch 5 taken 16 times.
✓ Branch 6 taken 64 times.
✓ Branch 7 taken 3376 times.
✓ Branch 8 taken 16 times.
✓ Branch 9 taken 16 times.
✓ Branch 10 taken 16 times.
✓ Branch 11 taken 16 times.
✓ Branch 12 taken 16 times.
✓ Branch 13 taken 16 times.
✓ Branch 14 taken 16 times.
✓ Branch 15 taken 16 times.
✓ Branch 16 taken 16 times.
✓ Branch 17 taken 16 times.
✓ Branch 18 taken 16 times.
✓ Branch 19 taken 16 times.
✓ Branch 20 taken 16 times.
✓ Branch 21 taken 16 times.
✓ Branch 22 taken 16 times.
✓ Branch 23 taken 16 times.
✓ Branch 24 taken 16 times.
✓ Branch 25 taken 16 times.
✓ Branch 26 taken 16 times.
✓ Branch 27 taken 16 times.
✓ Branch 28 taken 16 times.
✓ Branch 29 taken 16 times.
✓ Branch 30 taken 16 times.
✓ Branch 31 taken 16 times.
✓ Branch 32 taken 16 times.
✓ Branch 33 taken 16 times.
✓ Branch 34 taken 16 times.
✓ Branch 35 taken 16 times.
✓ Branch 36 taken 16 times.
✓ Branch 37 taken 16 times.
✓ Branch 38 taken 16 times.
✓ Branch 39 taken 16 times.
✓ Branch 40 taken 16 times.
✓ Branch 41 taken 16 times.
✓ Branch 42 taken 16 times.
4096 switch(i)
7256 {
7257 case iTriforce:
7258 16 tempitem.fam_type=1;
7259 16 break;
7260
7261 case iBigTri:
7262 16 tempitem.fam_type=0;
7263 16 break;
7264
7265 case iBombs:
7266 16 tempitem.fam_type=i_bomb;
7267 16 tempitem.power=4;
7268 16 tempitem.wpn=wBOMB;
7269 16 tempitem.wpn2=wBOOM;
7270 16 tempitem.misc1 = 50;
7271
7272
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 if(get_bit(deprecated_rules,qr_SLOWBOMBFUSES_DEP)) tempitem.misc1 = 200;
7273
7274 16 break;
7275
7276 case iSBomb:
7277 16 tempitem.fam_type=i_sbomb;
7278 16 tempitem.power=16;
7279 16 tempitem.wpn=wSBOMB;
7280 16 tempitem.wpn2=wSBOOM;
7281 16 tempitem.misc1 = 50;
7282
7283
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 if(get_bit(deprecated_rules,qr_SLOWBOMBFUSES_DEP)) tempitem.misc1 = 400;
7284
7285 16 break;
7286
7287 case iBook:
7288
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 if(get_bit(deprecated_rules, qr_FIREMAGICSPRITE_DEP))
7289 tempitem.wpn = wFIREMAGIC;
7290
7291 16 break;
7292
7293 case iSArrow:
7294 16 tempitem.wpn2 = get_bit(deprecated_rules,27) ? wSSPARKLE : 0; //qr_SASPARKLES
7295 16 tempitem.power=4;
7296 16 tempitem.flags|=ITEM_GAMEDATA;
7297 16 tempitem.wpn=wSARROW;
7298 16 break;
7299
7300 case iGArrow:
7301 16 tempitem.wpn2 = get_bit(deprecated_rules,28) ? wGSPARKLE : 0; //qr_GASPARKLES
7302 16 tempitem.power=8;
7303 16 tempitem.flags|=(ITEM_GAMEDATA|ITEM_FLAG1);
7304 16 tempitem.wpn=wGARROW;
7305 16 break;
7306
7307 case iBrang:
7308 16 tempitem.power=0;
7309 16 tempitem.wpn=wBRANG;
7310 16 tempitem.misc1=36;
7311 16 break;
7312
7313 case iMBrang:
7314 16 tempitem.wpn2 = get_bit(deprecated_rules,29) ? wMSPARKLE : 0; //qr_MBSPARKLES
7315 16 tempitem.power=0;
7316 16 tempitem.wpn=wMBRANG;
7317 16 break;
7318
7319 case iFBrang:
7320 16 tempitem.wpn3 = get_bit(deprecated_rules,30) ? wFSPARKLE : 0; //qr_FBSPARKLES
7321 16 tempitem.power=2;
7322 16 tempitem.wpn=wFBRANG;
7323 16 break;
7324
7325 case iBoots:
7326 16 tempitem.cost_amount[0] = get_bit(deprecated_rules,qr_MAGICBOOTS_DEP) ? 1 : 0;
7327 16 tempitem.power=7;
7328 16 break;
7329
7330 case iWand:
7331 16 tempitem.cost_amount[0] = get_bit(deprecated_rules,qr_MAGICWAND_DEP) ? 8 : 0;
7332 16 tempitem.power=2;
7333 16 tempitem.wpn=wWAND;
7334 16 tempitem.wpn3=wMAGIC;
7335 16 break;
7336
7337 case iBCandle:
7338 16 tempitem.cost_amount[0] = get_bit(deprecated_rules,qr_MAGICCANDLE_DEP) ? 4 : 0;
7339 16 tempitem.power=1;
7340 16 tempitem.flags|=(ITEM_GAMEDATA|ITEM_FLAG1);
7341 16 tempitem.wpn3=wFIRE;
7342 16 break;
7343
7344 case iRCandle:
7345 16 tempitem.cost_amount[0] = get_bit(deprecated_rules,qr_MAGICCANDLE_DEP) ? 4 : 0;
7346 16 tempitem.power=1;
7347 16 tempitem.wpn3=wFIRE;
7348 16 break;
7349
7350 case iSword:
7351 16 tempitem.power=1;
7352 16 tempitem.flags|= ITEM_FLAG4 |ITEM_FLAG2;
7353 16 tempitem.wpn=tempitem.wpn3=wSWORD;
7354 16 tempitem.wpn2=wSWORDSLASH;
7355 16 break;
7356
7357 case iWSword:
7358 16 tempitem.power=2;
7359 16 tempitem.flags|= ITEM_FLAG4 |ITEM_FLAG2;
7360 16 tempitem.wpn=tempitem.wpn3=wWSWORD;
7361 16 tempitem.wpn2=wWSWORDSLASH;
7362 16 break;
7363
7364 case iMSword:
7365 16 tempitem.power=4;
7366 16 tempitem.flags|= ITEM_FLAG4 |ITEM_FLAG2;
7367 16 tempitem.wpn=tempitem.wpn3=wMSWORD;
7368 16 tempitem.wpn2=wMSWORDSLASH;
7369 16 break;
7370
7371 case iXSword:
7372 16 tempitem.power=8;
7373 16 tempitem.flags|= ITEM_FLAG4 |ITEM_FLAG2;
7374 16 tempitem.wpn=tempitem.wpn3=wXSWORD;
7375 16 tempitem.wpn2=wXSWORDSLASH;
7376 16 break;
7377
7378 case iDivineProtection:
7379 16 tempitem.flags |= get_bit(deprecated_rules,qr_FLICKERINGDIVINEPROTECTIONROCKET_DEP) ? ITEM_FLAG1 : 0;
7380 16 tempitem.flags |= get_bit(deprecated_rules,qr_TRANSLUCENTDIVINEPROTECTIONROCKET_DEP) ? ITEM_FLAG2 : 0;
7381 16 tempitem.wpn=wDIVINEPROTECTION1A;
7382 16 tempitem.wpn2=wDIVINEPROTECTION1B;
7383 16 tempitem.wpn3=wDIVINEPROTECTIONS1A;
7384 16 tempitem.wpn4=wDIVINEPROTECTIONS1B;
7385 16 tempitem.wpn6=wDIVINEPROTECTION2A;
7386 16 tempitem.wpn7=wDIVINEPROTECTION2B;
7387 16 tempitem.wpn8=wDIVINEPROTECTIONS2A;
7388 16 tempitem.wpn9=wDIVINEPROTECTIONS2B;
7389 16 tempitem.wpn5 = iwDivineProtectionShieldFront;
7390 16 tempitem.wpn10 = iwDivineProtectionShieldBack;
7391 16 tempitem.misc1=512;
7392 16 tempitem.cost_amount[0]=64;
7393 16 break;
7394
7395 case iLens:
7396 16 tempitem.misc1=60;
7397 16 tempitem.flags |= get_qr(qr_ENABLEMAGIC) ? 0 : ITEM_RUPEE_MAGIC;
7398 16 tempitem.cost_amount[0] = get_qr(qr_ENABLEMAGIC) ? 2 : 1;
7399 16 break;
7400
7401 case iArrow:
7402 16 tempitem.power=2;
7403 16 tempitem.wpn=wARROW;
7404 16 break;
7405
7406 case iHoverBoots:
7407 16 tempitem.misc1=45;
7408 16 tempitem.wpn=iwHover;
7409 16 break;
7410
7411 case iDivineFire:
7412 16 tempitem.power=8;
7413 16 tempitem.wpn=wDIVINEFIRE1A;
7414 16 tempitem.wpn2=wDIVINEFIRE1B;
7415 16 tempitem.wpn3=wDIVINEFIRES1A;
7416 16 tempitem.wpn4=wDIVINEFIRES1B;
7417 16 tempitem.misc1 = 32;
7418 16 tempitem.misc2 = 200;
7419 16 tempitem.cost_amount[0]=32;
7420 16 break;
7421
7422 case iDivineEscape:
7423 16 tempitem.cost_amount[0]=32;
7424 16 break;
7425
7426 case iHookshot:
7427 16 tempitem.power=0;
7428 16 tempitem.flags&=~ITEM_FLAG1;
7429 16 tempitem.wpn=wHSHEAD;
7430 16 tempitem.wpn2=wHSCHAIN_H;
7431 16 tempitem.wpn4=wHSHANDLE;
7432 16 tempitem.wpn3=wHSCHAIN_V;
7433 16 tempitem.misc1=50;
7434 16 tempitem.misc2=100;
7435 16 break;
7436
7437 case iLongshot:
7438 16 tempitem.power=0;
7439 16 tempitem.flags&=~ITEM_FLAG1;
7440 16 tempitem.wpn=wLSHEAD;
7441 16 tempitem.wpn2=wLSCHAIN_H;
7442 16 tempitem.wpn4=wLSHANDLE;
7443 16 tempitem.wpn3=wLSCHAIN_V;
7444 16 tempitem.misc1=99;
7445 16 tempitem.misc2=100;
7446 16 break;
7447
7448 case iHammer:
7449 16 tempitem.power=4;
7450 16 tempitem.wpn=wHAMMER;
7451 16 tempitem.wpn2=iwHammerSmack;
7452 16 break;
7453
7454 case iCByrna:
7455 16 tempitem.power=1;
7456 16 tempitem.wpn=wCBYRNA;
7457 16 tempitem.wpn2=wCBYRNASLASH;
7458 16 tempitem.wpn3=wCBYRNAORB;
7459 16 tempitem.misc1=4;
7460 16 tempitem.misc2=16;
7461 16 tempitem.misc3=1;
7462 16 tempitem.cost_amount[0]=1;
7463 16 break;
7464
7465 case iWhistle:
7466 16 tempitem.wpn=wWIND;
7467 16 tempitem.misc1=3;
7468 16 tempitem.flags|=ITEM_FLAG1;
7469 16 break;
7470
7471 case iBRing:
7472 16 tempitem.power=2;
7473 16 tempitem.misc1=spBLUE;
7474 16 break;
7475
7476 case iRRing:
7477 16 tempitem.power=4;
7478 16 tempitem.misc1=spRED;
7479 16 break;
7480
7481 case iGRing:
7482 16 tempitem.power=8;
7483 16 tempitem.misc1=spGOLD;
7484 16 break;
7485
7486 case iSpinScroll:
7487 16 tempitem.power = 2;
7488 16 tempitem.misc1 = 1;
7489 16 break;
7490
7491 case iL2SpinScroll:
7492 16 tempitem.family=itype_spinscroll2;
7493 16 tempitem.fam_type=1;
7494 16 tempitem.cost_amount[0]=8;
7495 16 tempitem.power=2;
7496 16 tempitem.misc1 = 20;
7497 16 break;
7498
7499 case iQuakeScroll:
7500 16 tempitem.misc1=0x10;
7501 16 tempitem.misc2=64;
7502 16 break;
7503
7504 case iL2QuakeScroll:
7505 16 tempitem.family=itype_quakescroll2;
7506 16 tempitem.fam_type=1;
7507 16 tempitem.power = 2;
7508 16 tempitem.misc1=0x20;
7509 16 tempitem.misc2=192;
7510 16 tempitem.cost_amount[0]=8;
7511 16 break;
7512
7513 case iChargeRing:
7514 16 tempitem.misc1=64;
7515 16 tempitem.misc2=128;
7516 16 break;
7517
7518 case iL2ChargeRing:
7519 16 tempitem.misc1=32;
7520 16 tempitem.misc2=64;
7521 16 break;
7522
7523 case iOldGlove:
7524 16 tempitem.flags |= ITEM_FLAG1;
7525
7526 //fallthrough
7527 case iBombBagL4:
7528 case iWalletL3:
7529 case iQuiverL4:
7530 case iBracelet:
7531 80 tempitem.power = 1;
7532 80 break;
7533
7534 case iL2Bracelet:
7535 16 tempitem.power = 2;
7536 16 break;
7537
7538 case iMKey:
7539 16 tempitem.power=0xFF;
7540 16 tempitem.flags |= ITEM_FLAG1;
7541 16 break;
7542 }
7543 4096 }
7544
7545
2/2
✓ Branch 0 taken 28672 times.
✓ Branch 1 taken 4096 times.
32768 if(s_version < 7)
7546 {
7547
2/2
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 4032 times.
4096 switch(i)
7548 {
7549 case iStoneAgony:
7550 case iStompBoots:
7551 case iPerilRing:
7552 case iWhimsicalRing:
7553 {
7554 64 reset_itembuf(&tempitem, i);
7555 64 strcpy(item_string[i],old_item_string[i]);
7556 64 break;
7557 }
7558 }
7559 4096 }
7560
7561
2/2
✓ Branch 0 taken 28672 times.
✓ Branch 1 taken 4096 times.
32768 if(s_version < 8) // May 2007: Some corrections.
7562 {
7563
7/7
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 16 times.
✓ Branch 2 taken 48 times.
✓ Branch 3 taken 3968 times.
✓ Branch 4 taken 16 times.
✓ Branch 5 taken 16 times.
✓ Branch 6 taken 16 times.
4096 switch(i)
7564 {
7565 case iMShield:
7566 16 tempitem.misc1|=shFLAME;
7567 16 tempitem.misc2|=shFIREBALL|shMAGIC;
7568
7569
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(get_qr(qr_SWORDMIRROR))
7570 {
7571 tempitem.misc2 |= shSWORD;
7572 }
7573
7574 // fallthrough
7575 case iShield:
7576 32 tempitem.misc1|=shFIREBALL|shSWORD|shMAGIC;
7577
7578 // fallthrough
7579 case iSShield:
7580 48 tempitem.misc1|=shROCK|shARROW|shBRANG|shSCRIPT;
7581
7582
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 48 times.
48 if(get_bit(deprecated_rules,102)) //qr_REFLECTROCKS
7583 {
7584 tempitem.misc2 |= shROCK;
7585 }
7586
7587 48 break;
7588
7589 case iWhispRing:
7590 16 tempitem.power=1;
7591 16 tempitem.flags|=ITEM_GAMEDATA|ITEM_FLAG1;
7592 16 tempitem.misc1 = 3;
7593 16 break;
7594
7595 case iL2WhispRing:
7596 16 tempitem.power=0;
7597 16 tempitem.flags|=ITEM_GAMEDATA|ITEM_FLAG1;
7598 16 tempitem.misc1 = 3;
7599 16 break;
7600
7601 case iL2Ladder:
7602 case iBow:
7603 case iCByrna:
7604 48 tempitem.power = 1;
7605 48 break;
7606 }
7607 4096 }
7608
7609
4/4
✓ Branch 0 taken 4096 times.
✓ Branch 1 taken 28672 times.
✓ Branch 2 taken 4080 times.
✓ Branch 3 taken 16 times.
32768 if(s_version < 9 && i==iClock)
7610 {
7611 16 tempitem.misc1 = get_bit(deprecated_rules, qr_TEMPCLOCKS_DEP) ? 256 : 0;
7612 16 }
7613
7614 //add the misc flag for bomb
7615
4/4
✓ Branch 0 taken 4096 times.
✓ Branch 1 taken 28672 times.
✓ Branch 2 taken 4080 times.
✓ Branch 3 taken 16 times.
32768 if(s_version < 10 && tempitem.family == itype_bomb)
7616 {
7617 16 tempitem.flags = (tempitem.flags & ~ITEM_FLAG1) | (get_qr(qr_LONGBOMBBOOM_DEP) ? ITEM_FLAG1 : 0);
7618 16 }
7619
7620
4/4
✓ Branch 0 taken 4096 times.
✓ Branch 1 taken 28672 times.
✓ Branch 2 taken 4064 times.
✓ Branch 3 taken 32 times.
32768 if(s_version < 11 && tempitem.family == itype_triforcepiece)
7621 {
7622 32 tempitem.flags = (tempitem.fam_type ? ITEM_GAMEDATA : 0);
7623 32 tempitem.playsound = (tempitem.fam_type ? WAV_SCALE : WAV_CLEARED);
7624 32 }
7625
7626
2/2
✓ Branch 0 taken 28672 times.
✓ Branch 1 taken 4096 times.
32768 if(s_version < 12) // June 2007: More Misc. attributes.
7627 {
7628
5/5
✓ Branch 0 taken 32 times.
✓ Branch 1 taken 4016 times.
✓ Branch 2 taken 16 times.
✓ Branch 3 taken 16 times.
✓ Branch 4 taken 16 times.
4096 switch(i)
7629 {
7630 case iFBrang:
7631 16 tempitem.misc4 |= shFIREBALL|shSWORD|shMAGIC;
7632
7633 //fallthrough
7634 case iMBrang:
7635 32 tempitem.misc3 |= shSWORD|shMAGIC;
7636
7637 //fallthrough
7638 case iHookshot:
7639 case iLongshot:
7640 //fallthrough
7641 64 tempitem.misc3 |= shFIREBALL;
7642
7643 case iBrang:
7644 80 tempitem.misc3 |= shBRANG|shROCK|shARROW;
7645 80 break;
7646 }
7647
7648
16/16
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 48 times.
✓ Branch 2 taken 16 times.
✓ Branch 3 taken 16 times.
✓ Branch 4 taken 16 times.
✓ Branch 5 taken 64 times.
✓ Branch 6 taken 32 times.
✓ Branch 7 taken 1956 times.
✓ Branch 8 taken 16 times.
✓ Branch 9 taken 16 times.
✓ Branch 10 taken 32 times.
✓ Branch 11 taken 48 times.
✓ Branch 12 taken 48 times.
✓ Branch 13 taken 1740 times.
✓ Branch 14 taken 16 times.
✓ Branch 15 taken 16 times.
4096 switch(tempitem.family)
7649 {
7650 case itype_hoverboots:
7651 16 tempitem.usesound = WAV_ZN1HOVER;
7652 16 break;
7653
7654 case itype_wand:
7655 16 tempitem.usesound = WAV_WAND;
7656 16 break;
7657
7658 case itype_book:
7659 16 tempitem.usesound = WAV_FIRE;
7660 16 break;
7661
7662 case itype_arrow:
7663 48 tempitem.usesound = WAV_ARROW;
7664 48 break;
7665
7666 case itype_hookshot:
7667 32 tempitem.usesound = WAV_HOOKSHOT;
7668 32 break;
7669
7670 case itype_brang:
7671 48 tempitem.usesound = WAV_BRANG;
7672 48 break;
7673
7674 case itype_shield:
7675 48 tempitem.usesound = WAV_CHINK;
7676 48 break;
7677
7678 case itype_sword:
7679 1740 tempitem.usesound = WAV_SWORD;
7680 1740 break;
7681
7682 case itype_whistle:
7683 16 tempitem.usesound = WAV_WHISTLE;
7684 16 break;
7685
7686 case itype_hammer:
7687 16 tempitem.usesound = WAV_HAMMER;
7688 16 break;
7689
7690 case itype_divinefire:
7691 16 tempitem.usesound = WAV_ZN1DIVINEFIRE;
7692 16 break;
7693
7694 case itype_divineescape:
7695 16 tempitem.usesound = WAV_ZN1DIVINEESCAPE;
7696 16 break;
7697
7698 case itype_divineprotection:
7699 16 tempitem.usesound = WAV_ZN1DIVINEPROTECTION1;
7700 16 break;
7701
7702 case itype_bomb:
7703 case itype_sbomb:
7704 case itype_quakescroll:
7705 case itype_quakescroll2:
7706 64 tempitem.usesound = WAV_BOMB;
7707 64 break;
7708
7709 case itype_spinscroll:
7710 case itype_spinscroll2:
7711 32 tempitem.usesound = WAV_ZN1SPINATTACK;
7712 32 break;
7713 }
7714 4096 }
7715
7716
2/2
✓ Branch 0 taken 28672 times.
✓ Branch 1 taken 4096 times.
32768 if(s_version < 13) // July 2007
7717 {
7718
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 4080 times.
4096 if(tempitem.family == itype_whistle)
7719 {
7720 16 tempitem.misc1 = (tempitem.power==2 ? 4 : 3);
7721 16 tempitem.power = 1;
7722 16 tempitem.flags|=ITEM_FLAG1;
7723 16 }
7724
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 4064 times.
4080 else if(tempitem.family == itype_wand)
7725 16 tempitem.flags|=ITEM_FLAG1;
7726
2/2
✓ Branch 0 taken 4048 times.
✓ Branch 1 taken 16 times.
4064 else if(tempitem.family == itype_book)
7727 {
7728 16 tempitem.flags|=ITEM_FLAG1;
7729 16 tempitem.power = 2;
7730 16 }
7731 4096 }
7732
7733
2/2
✓ Branch 0 taken 28672 times.
✓ Branch 1 taken 4096 times.
32768 if(s_version < 14) // August 2007
7734 {
7735
2/2
✓ Branch 0 taken 32 times.
✓ Branch 1 taken 4064 times.
4096 if(tempitem.family == itype_fairy)
7736 {
7737 32 tempitem.usesound = WAV_SCALE;
7738
7739
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 32 times.
32 if(tempitem.fam_type)
7740 32 tempitem.misc3=50;
7741 32 }
7742
2/2
✓ Branch 0 taken 4032 times.
✓ Branch 1 taken 32 times.
4064 else if(tempitem.family == itype_potion)
7743 {
7744 32 tempitem.flags |= ITEM_GAINOLD;
7745 32 }
7746 4096 }
7747
7748
2/2
✓ Branch 0 taken 28672 times.
✓ Branch 1 taken 4096 times.
32768 if(s_version < 17) // November 2007
7749 {
7750
3/4
✓ Branch 0 taken 32 times.
✓ Branch 1 taken 4064 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 32 times.
4096 if(tempitem.family == itype_candle && !tempitem.wpn3)
7751 {
7752 tempitem.wpn3 = wFIRE;
7753 }
7754
4/4
✓ Branch 0 taken 48 times.
✓ Branch 1 taken 4048 times.
✓ Branch 2 taken 32 times.
✓ Branch 3 taken 16 times.
4096 else if(tempitem.family == itype_arrow && tempitem.power>4)
7755 {
7756 16 tempitem.flags|=ITEM_FLAG1;
7757 16 }
7758 4096 }
7759
7760
2/2
✓ Branch 0 taken 28672 times.
✓ Branch 1 taken 4096 times.
32768 if(s_version < 18) // New Year's Eve 2007
7761 {
7762
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 4080 times.
4096 if(tempitem.family == itype_whistle)
7763 16 tempitem.misc2 = 8; // Use the Whistle warp ring
7764
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 4064 times.
4080 else if(tempitem.family == itype_bait)
7765 16 tempitem.misc1 = 768; // Frames until it goes
7766
2/2
✓ Branch 0 taken 4032 times.
✓ Branch 1 taken 32 times.
4064 else if(tempitem.family == itype_triforcepiece)
7767 {
7768
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 16 times.
32 if(tempitem.flags & ITEM_GAMEDATA)
7769 {
7770 16 tempitem.misc2 = 1; // Cutscene 1
7771 16 tempitem.flags |= ITEM_FLAG1; // Side Warp Out
7772 16 }
7773 32 }
7774 4096 }
7775
7776
2/2
✓ Branch 0 taken 28672 times.
✓ Branch 1 taken 4096 times.
32768 if(s_version < 19) // January 2008
7777 {
7778
2/2
✓ Branch 0 taken 4080 times.
✓ Branch 1 taken 16 times.
4096 if(tempitem.family == itype_divineprotection)
7779 {
7780 16 tempitem.flags |= get_bit(deprecated_rules,qr_NOBOMBPALFLASH+1)?ITEM_FLAG3:0;
7781 16 tempitem.flags |= get_bit(deprecated_rules,qr_NOBOMBPALFLASH+2)?ITEM_FLAG4:0;
7782 16 }
7783 4096 }
7784
7785
2/2
✓ Branch 0 taken 28672 times.
✓ Branch 1 taken 4096 times.
32768 if(s_version < 20) // October 2008
7786 {
7787
2/2
✓ Branch 0 taken 4080 times.
✓ Branch 1 taken 16 times.
4096 if(tempitem.family == itype_divineprotection)
7788 {
7789 16 tempitem.wpn6=wDIVINEPROTECTION2A;
7790 16 tempitem.wpn7=wDIVINEPROTECTION2B;
7791 16 tempitem.wpn8=wDIVINEPROTECTIONS2A;
7792 16 tempitem.wpn9=wDIVINEPROTECTIONS2B;
7793 16 tempitem.wpn5 = iwDivineProtectionShieldFront;
7794 16 tempitem.wpn10 = iwDivineProtectionShieldBack;
7795 16 }
7796 4096 }
7797
7798
2/2
✓ Branch 0 taken 28672 times.
✓ Branch 1 taken 4096 times.
32768 if(s_version < 21) // November 2008
7799 {
7800
1/2
✓ Branch 0 taken 4096 times.
✗ Branch 1 not taken.
4096 if(tempitem.flags & 0x0100) // ITEM_SLASH
7801 {
7802 tempitem.flags &= ~0x0100;
7803
7804 if(tempitem.family == itype_sword ||
7805 tempitem.family == itype_wand ||
7806 tempitem.family == itype_candle ||
7807 tempitem.family == itype_cbyrna)
7808 {
7809 tempitem.flags |= ITEM_FLAG4;
7810 }
7811 }
7812 4096 }
7813
7814
2/2
✓ Branch 0 taken 28672 times.
✓ Branch 1 taken 4096 times.
32768 if(s_version < 22) // September 2009
7815 {
7816
4/4
✓ Branch 0 taken 4080 times.
✓ Branch 1 taken 16 times.
✓ Branch 2 taken 16 times.
✓ Branch 3 taken 4064 times.
4096 if(tempitem.family == itype_sbomb || tempitem.family == itype_bomb)
7817 {
7818 32 tempitem.misc3 = tempitem.power/2;
7819 32 }
7820 4096 }
7821
7822
2/2
✓ Branch 0 taken 28672 times.
✓ Branch 1 taken 4096 times.
32768 if(s_version < 23) // March 2011
7823 {
7824
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 4080 times.
4096 if(tempitem.family == itype_divinefire)
7825 16 tempitem.wpn5 = wFIRE;
7826
2/2
✓ Branch 0 taken 4064 times.
✓ Branch 1 taken 16 times.
4080 else if(tempitem.family == itype_book)
7827 16 tempitem.wpn2 = wFIRE;
7828 4096 }
7829
7830 // Version 25: Bomb bags were acting as though "super bombs also" was checked
7831 // whether it was or not, and a lot of existing quests depended on the
7832 // incorrect behavior.
7833
2/2
✓ Branch 0 taken 28672 times.
✓ Branch 1 taken 4096 times.
32768 if(s_version < 25) // January 2012
7834 {
7835
2/2
✓ Branch 0 taken 4032 times.
✓ Branch 1 taken 64 times.
4096 if(tempitem.family == itype_bombbag)
7836 64 tempitem.flags |= 16;
7837
7838
2/2
✓ Branch 0 taken 4080 times.
✓ Branch 1 taken 16 times.
4096 if(tempitem.family == itype_divinefire)
7839 16 tempitem.flags |= ITEM_FLAG3; // Sideview gravity flag
7840 4096 }
7841
7842
2/2
✓ Branch 0 taken 8960 times.
✓ Branch 1 taken 23808 times.
32768 if( version < 0x254) //Nuke greyed-out flags/values from <=2.53, in case they are used in 2.54/2.55
7843 {
7844
60/60
✓ Branch 0 taken 7811 times.
✓ Branch 1 taken 277 times.
✓ Branch 2 taken 274 times.
✓ Branch 3 taken 222 times.
✓ Branch 4 taken 138 times.
✓ Branch 5 taken 93 times.
✓ Branch 6 taken 184 times.
✓ Branch 7 taken 183 times.
✓ Branch 8 taken 107 times.
✓ Branch 9 taken 302 times.
✓ Branch 10 taken 276 times.
✓ Branch 11 taken 183 times.
✓ Branch 12 taken 283 times.
✓ Branch 13 taken 184 times.
✓ Branch 14 taken 92 times.
✓ Branch 15 taken 184 times.
✓ Branch 16 taken 107 times.
✓ Branch 17 taken 92 times.
✓ Branch 18 taken 279 times.
✓ Branch 19 taken 93 times.
✓ Branch 20 taken 94 times.
✓ Branch 21 taken 184 times.
✓ Branch 22 taken 92 times.
✓ Branch 23 taken 93 times.
✓ Branch 24 taken 92 times.
✓ Branch 25 taken 92 times.
✓ Branch 26 taken 92 times.
✓ Branch 27 taken 107 times.
✓ Branch 28 taken 92 times.
✓ Branch 29 taken 93 times.
✓ Branch 30 taken 92 times.
✓ Branch 31 taken 93 times.
✓ Branch 32 taken 184 times.
✓ Branch 33 taken 368 times.
✓ Branch 34 taken 94 times.
✓ Branch 35 taken 92 times.
✓ Branch 36 taken 168 times.
✓ Branch 37 taken 368 times.
✓ Branch 38 taken 92 times.
✓ Branch 39 taken 92 times.
✓ Branch 40 taken 92 times.
✓ Branch 41 taken 92 times.
✓ Branch 42 taken 92 times.
✓ Branch 43 taken 185 times.
✓ Branch 44 taken 184 times.
✓ Branch 45 taken 92 times.
✓ Branch 46 taken 277 times.
✓ Branch 47 taken 278 times.
✓ Branch 48 taken 372 times.
✓ Branch 49 taken 92 times.
✓ Branch 50 taken 92 times.
✓ Branch 51 taken 92 times.
✓ Branch 52 taken 92 times.
✓ Branch 53 taken 92 times.
✓ Branch 54 taken 93 times.
✓ Branch 55 taken 2541 times.
✓ Branch 56 taken 983 times.
✓ Branch 57 taken 277 times.
✓ Branch 58 taken 1135 times.
✓ Branch 59 taken 2617 times.
23808 switch(tempitem.family)
7845 {
7846 case itype_sword:
7847 {
7848 7811 tempitem.flags &= ~(ITEM_FLAG5);
7849 7811 tempitem.misc3 = 0;
7850 7811 tempitem.misc4 = 0;
7851 7811 tempitem.misc5 = 0;
7852 7811 tempitem.misc6 = 0;
7853 7811 tempitem.misc7 = 0;
7854 7811 tempitem.misc8 = 0;
7855 7811 tempitem.misc9 = 0;
7856 7811 tempitem.misc10 = 0;
7857 7811 tempitem.wpn4 = 0;
7858 7811 tempitem.wpn5 = 0;
7859 7811 tempitem.wpn6 = 0;
7860 7811 tempitem.wpn7 = 0;
7861 7811 tempitem.wpn8 = 0;
7862 7811 tempitem.wpn9 = 0;
7863 7811 tempitem.wpn10 = 0;
7864 7811 break;
7865 }
7866 case itype_brang:
7867 {
7868 277 tempitem.flags &= ~(ITEM_FLAG4 | ITEM_FLAG5);
7869 277 tempitem.misc2 = 0;
7870 277 tempitem.misc5 = 0;
7871 277 tempitem.misc6 = 0;
7872 277 tempitem.misc7 = 0;
7873 277 tempitem.misc8 = 0;
7874 277 tempitem.misc9 = 0;
7875 277 tempitem.misc10 = 0;
7876 277 tempitem.wpn4 = 0;
7877 277 tempitem.wpn5 = 0;
7878 277 tempitem.wpn6 = 0;
7879 277 tempitem.wpn7 = 0;
7880 277 tempitem.wpn8 = 0;
7881 277 tempitem.wpn9 = 0;
7882 277 tempitem.wpn10 = 0;
7883 277 break;
7884 }
7885 case itype_arrow:
7886 {
7887 274 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
7888 274 tempitem.misc2 = 0;
7889 274 tempitem.misc3 = 0;
7890 274 tempitem.misc4 = 0;
7891 274 tempitem.misc5 = 0;
7892 274 tempitem.misc6 = 0;
7893 274 tempitem.misc7 = 0;
7894 274 tempitem.misc8 = 0;
7895 274 tempitem.misc9 = 0;
7896 274 tempitem.misc10 = 0;
7897 274 tempitem.wpn4 = 0;
7898 274 tempitem.wpn5 = 0;
7899 274 tempitem.wpn6 = 0;
7900 274 tempitem.wpn7 = 0;
7901 274 tempitem.wpn8 = 0;
7902 274 tempitem.wpn9 = 0;
7903 274 tempitem.wpn10 = 0;
7904 274 break;
7905 }
7906 case itype_candle:
7907 {
7908 222 tempitem.flags &= ~ (ITEM_FLAG3 | ITEM_FLAG5);
7909 222 tempitem.misc1 = 0;
7910 222 tempitem.misc2 = 0;
7911 222 tempitem.misc3 = 0;
7912 222 tempitem.misc4 = 0;
7913 222 tempitem.misc5 = 0;
7914 222 tempitem.misc6 = 0;
7915 222 tempitem.misc7 = 0;
7916 222 tempitem.misc8 = 0;
7917 222 tempitem.misc9 = 0;
7918 222 tempitem.misc10 = 0;
7919 222 tempitem.wpn4 = 0;
7920 222 tempitem.wpn5 = 0;
7921 222 tempitem.wpn6 = 0;
7922 222 tempitem.wpn7 = 0;
7923 222 tempitem.wpn8 = 0;
7924 222 tempitem.wpn9 = 0;
7925 222 tempitem.wpn10 = 0;
7926 222 break;
7927 }
7928 case itype_whistle:
7929 {
7930 138 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
7931 138 tempitem.misc3 = 0;
7932 138 tempitem.misc4 = 0;
7933 138 tempitem.misc5 = 0;
7934 138 tempitem.misc6 = 0;
7935 138 tempitem.misc7 = 0;
7936 138 tempitem.misc8 = 0;
7937 138 tempitem.misc9 = 0;
7938 138 tempitem.misc10 = 0;
7939 138 tempitem.wpn2 = 0;
7940 138 tempitem.wpn3 = 0;
7941 138 tempitem.wpn4 = 0;
7942 138 tempitem.wpn5 = 0;
7943 138 tempitem.wpn6 = 0;
7944 138 tempitem.wpn7 = 0;
7945 138 tempitem.wpn8 = 0;
7946 138 tempitem.wpn9 = 0;
7947 138 tempitem.wpn10 = 0;
7948 138 break;
7949 }
7950 case itype_bait:
7951 {
7952 93 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
7953 93 tempitem.misc2 = 0;
7954 93 tempitem.misc3 = 0;
7955 93 tempitem.misc4 = 0;
7956 93 tempitem.misc5 = 0;
7957 93 tempitem.misc6 = 0;
7958 93 tempitem.misc7 = 0;
7959 93 tempitem.misc8 = 0;
7960 93 tempitem.misc9 = 0;
7961 93 tempitem.misc10 = 0;
7962 93 tempitem.wpn2 = 0;
7963 93 tempitem.wpn3 = 0;
7964 93 tempitem.wpn4 = 0;
7965 93 tempitem.wpn5 = 0;
7966 93 tempitem.wpn6 = 0;
7967 93 tempitem.wpn7 = 0;
7968 93 tempitem.wpn8 = 0;
7969 93 tempitem.wpn9 = 0;
7970 93 tempitem.wpn10 = 0;
7971 93 break;
7972 }
7973 case itype_letter:
7974 {
7975 184 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
7976 184 tempitem.misc1 = 0;
7977 184 tempitem.misc2 = 0;
7978 184 tempitem.misc3 = 0;
7979 184 tempitem.misc4 = 0;
7980 184 tempitem.misc5 = 0;
7981 184 tempitem.misc6 = 0;
7982 184 tempitem.misc7 = 0;
7983 184 tempitem.misc8 = 0;
7984 184 tempitem.misc9 = 0;
7985 184 tempitem.misc10 = 0;
7986 184 tempitem.wpn = 0;
7987 184 tempitem.wpn2 = 0;
7988 184 tempitem.wpn3 = 0;
7989 184 tempitem.wpn4 = 0;
7990 184 tempitem.wpn5 = 0;
7991 184 tempitem.wpn6 = 0;
7992 184 tempitem.wpn7 = 0;
7993 184 tempitem.wpn8 = 0;
7994 184 tempitem.wpn9 = 0;
7995 184 tempitem.wpn10 = 0;
7996 184 break;
7997 }
7998 case itype_potion:
7999 {
8000 183 tempitem.flags &= ~ (ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8001 183 tempitem.misc3 = 0;
8002 183 tempitem.misc4 = 0;
8003 183 tempitem.misc5 = 0;
8004 183 tempitem.misc6 = 0;
8005 183 tempitem.misc7 = 0;
8006 183 tempitem.misc8 = 0;
8007 183 tempitem.misc9 = 0;
8008 183 tempitem.misc10 = 0;
8009 183 tempitem.wpn = 0;
8010 183 tempitem.wpn2 = 0;
8011 183 tempitem.wpn3 = 0;
8012 183 tempitem.wpn4 = 0;
8013 183 tempitem.wpn5 = 0;
8014 183 tempitem.wpn6 = 0;
8015 183 tempitem.wpn7 = 0;
8016 183 tempitem.wpn8 = 0;
8017 183 tempitem.wpn9 = 0;
8018 183 tempitem.wpn10 = 0;
8019 183 break;
8020 }
8021 case itype_wand:
8022 {
8023 107 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG5);
8024 107 tempitem.misc1 = 0;
8025 107 tempitem.misc2 = 0;
8026 107 tempitem.misc3 = 0;
8027 107 tempitem.misc4 = 0;
8028 107 tempitem.misc5 = 0;
8029 107 tempitem.misc6 = 0;
8030 107 tempitem.misc7 = 0;
8031 107 tempitem.misc8 = 0;
8032 107 tempitem.misc9 = 0;
8033 107 tempitem.misc10 = 0;
8034 107 tempitem.wpn4 = 0;
8035 107 tempitem.wpn5 = 0;
8036 107 tempitem.wpn6 = 0;
8037 107 tempitem.wpn7 = 0;
8038 107 tempitem.wpn8 = 0;
8039 107 tempitem.wpn9 = 0;
8040 107 tempitem.wpn10 = 0;
8041 107 break;
8042 }
8043 case itype_ring:
8044 {
8045 302 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8046 302 tempitem.misc2 = 0;
8047 302 tempitem.misc3 = 0;
8048 302 tempitem.misc4 = 0;
8049 302 tempitem.misc5 = 0;
8050 302 tempitem.misc6 = 0;
8051 302 tempitem.misc7 = 0;
8052 302 tempitem.misc8 = 0;
8053 302 tempitem.misc9 = 0;
8054 302 tempitem.misc10 = 0;
8055 302 tempitem.wpn = 0;
8056 302 tempitem.wpn2 = 0;
8057 302 tempitem.wpn3 = 0;
8058 302 tempitem.wpn4 = 0;
8059 302 tempitem.wpn5 = 0;
8060 302 tempitem.wpn6 = 0;
8061 302 tempitem.wpn7 = 0;
8062 302 tempitem.wpn8 = 0;
8063 302 tempitem.wpn9 = 0;
8064 302 tempitem.wpn10 = 0;
8065 302 break;
8066 }
8067 case itype_wallet:
8068 {
8069 276 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8070 276 tempitem.misc3 = 0;
8071 276 tempitem.misc4 = 0;
8072 276 tempitem.misc5 = 0;
8073 276 tempitem.misc6 = 0;
8074 276 tempitem.misc7 = 0;
8075 276 tempitem.misc8 = 0;
8076 276 tempitem.misc9 = 0;
8077 276 tempitem.misc10 = 0;
8078 276 tempitem.wpn = 0;
8079 276 tempitem.wpn2 = 0;
8080 276 tempitem.wpn3 = 0;
8081 276 tempitem.wpn4 = 0;
8082 276 tempitem.wpn5 = 0;
8083 276 tempitem.wpn6 = 0;
8084 276 tempitem.wpn7 = 0;
8085 276 tempitem.wpn8 = 0;
8086 276 tempitem.wpn9 = 0;
8087 276 tempitem.wpn10 = 0;
8088 276 break;
8089 }
8090 case itype_amulet:
8091 {
8092 183 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8093 183 tempitem.misc1 = 0;
8094 183 tempitem.misc2 = 0;
8095 183 tempitem.misc3 = 0;
8096 183 tempitem.misc4 = 0;
8097 183 tempitem.misc5 = 0;
8098 183 tempitem.misc6 = 0;
8099 183 tempitem.misc7 = 0;
8100 183 tempitem.misc8 = 0;
8101 183 tempitem.misc9 = 0;
8102 183 tempitem.misc10 = 0;
8103 183 tempitem.wpn = 0;
8104 183 tempitem.wpn2 = 0;
8105 183 tempitem.wpn3 = 0;
8106 183 tempitem.wpn4 = 0;
8107 183 tempitem.wpn5 = 0;
8108 183 tempitem.wpn6 = 0;
8109 183 tempitem.wpn7 = 0;
8110 183 tempitem.wpn8 = 0;
8111 183 tempitem.wpn9 = 0;
8112 183 tempitem.wpn10 = 0;
8113 183 break;
8114 }
8115 case itype_shield:
8116 {
8117 283 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8118 283 tempitem.misc3 = 0;
8119 283 tempitem.misc4 = 0;
8120 283 tempitem.misc5 = 0;
8121 283 tempitem.misc6 = 0;
8122 283 tempitem.misc7 = 0;
8123 283 tempitem.misc8 = 0;
8124 283 tempitem.misc9 = 0;
8125 283 tempitem.misc10 = 0;
8126 283 tempitem.wpn = 0;
8127 283 tempitem.wpn2 = 0;
8128 283 tempitem.wpn3 = 0;
8129 283 tempitem.wpn4 = 0;
8130 283 tempitem.wpn5 = 0;
8131 283 tempitem.wpn6 = 0;
8132 283 tempitem.wpn7 = 0;
8133 283 tempitem.wpn8 = 0;
8134 283 tempitem.wpn9 = 0;
8135 283 tempitem.wpn10 = 0;
8136 283 break;
8137 }
8138 case itype_bow:
8139 {
8140 184 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8141 184 tempitem.misc1 = 0;
8142 184 tempitem.misc2 = 0;
8143 184 tempitem.misc3 = 0;
8144 184 tempitem.misc4 = 0;
8145 184 tempitem.misc5 = 0;
8146 184 tempitem.misc6 = 0;
8147 184 tempitem.misc7 = 0;
8148 184 tempitem.misc8 = 0;
8149 184 tempitem.misc9 = 0;
8150 184 tempitem.misc10 = 0;
8151 184 tempitem.wpn = 0;
8152 184 tempitem.wpn2 = 0;
8153 184 tempitem.wpn3 = 0;
8154 184 tempitem.wpn4 = 0;
8155 184 tempitem.wpn5 = 0;
8156 184 tempitem.wpn6 = 0;
8157 184 tempitem.wpn7 = 0;
8158 184 tempitem.wpn8 = 0;
8159 184 tempitem.wpn9 = 0;
8160 184 tempitem.wpn10 = 0;
8161 184 break;
8162 }
8163 case itype_raft:
8164 {
8165 92 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8166 92 tempitem.misc1 = 0;
8167 92 tempitem.misc2 = 0;
8168 92 tempitem.misc3 = 0;
8169 92 tempitem.misc4 = 0;
8170 92 tempitem.misc5 = 0;
8171 92 tempitem.misc6 = 0;
8172 92 tempitem.misc7 = 0;
8173 92 tempitem.misc8 = 0;
8174 92 tempitem.misc9 = 0;
8175 92 tempitem.misc10 = 0;
8176 92 tempitem.wpn = 0;
8177 92 tempitem.wpn2 = 0;
8178 92 tempitem.wpn3 = 0;
8179 92 tempitem.wpn4 = 0;
8180 92 tempitem.wpn5 = 0;
8181 92 tempitem.wpn6 = 0;
8182 92 tempitem.wpn7 = 0;
8183 92 tempitem.wpn8 = 0;
8184 92 tempitem.wpn9 = 0;
8185 92 tempitem.wpn10 = 0;
8186 92 break;
8187 }
8188 case itype_ladder:
8189 {
8190 184 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8191 184 tempitem.misc1 = 0;
8192 184 tempitem.misc2 = 0;
8193 184 tempitem.misc3 = 0;
8194 184 tempitem.misc4 = 0;
8195 184 tempitem.misc5 = 0;
8196 184 tempitem.misc6 = 0;
8197 184 tempitem.misc7 = 0;
8198 184 tempitem.misc8 = 0;
8199 184 tempitem.misc9 = 0;
8200 184 tempitem.misc10 = 0;
8201 184 tempitem.wpn = 0;
8202 184 tempitem.wpn2 = 0;
8203 184 tempitem.wpn3 = 0;
8204 184 tempitem.wpn4 = 0;
8205 184 tempitem.wpn5 = 0;
8206 184 tempitem.wpn6 = 0;
8207 184 tempitem.wpn7 = 0;
8208 184 tempitem.wpn8 = 0;
8209 184 tempitem.wpn9 = 0;
8210 184 tempitem.wpn10 = 0;
8211 184 break;
8212 }
8213 case itype_book:
8214 {
8215 107 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8216 107 tempitem.misc1 = 0;
8217 107 tempitem.misc2 = 0;
8218 107 tempitem.misc3 = 0;
8219 107 tempitem.misc4 = 0;
8220 107 tempitem.misc5 = 0;
8221 107 tempitem.misc6 = 0;
8222 107 tempitem.misc7 = 0;
8223 107 tempitem.misc8 = 0;
8224 107 tempitem.misc9 = 0;
8225 107 tempitem.misc10 = 0;
8226 107 tempitem.wpn3 = 0;
8227 107 tempitem.wpn4 = 0;
8228 107 tempitem.wpn5 = 0;
8229 107 tempitem.wpn6 = 0;
8230 107 tempitem.wpn7 = 0;
8231 107 tempitem.wpn8 = 0;
8232 107 tempitem.wpn9 = 0;
8233 107 tempitem.wpn10 = 0;
8234 107 break;
8235 }
8236 case itype_magickey:
8237 {
8238 92 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8239 92 tempitem.misc1 = 0;
8240 92 tempitem.misc2 = 0;
8241 92 tempitem.misc3 = 0;
8242 92 tempitem.misc4 = 0;
8243 92 tempitem.misc5 = 0;
8244 92 tempitem.misc6 = 0;
8245 92 tempitem.misc7 = 0;
8246 92 tempitem.misc8 = 0;
8247 92 tempitem.misc9 = 0;
8248 92 tempitem.misc10 = 0;
8249 92 tempitem.wpn = 0;
8250 92 tempitem.wpn2 = 0;
8251 92 tempitem.wpn3 = 0;
8252 92 tempitem.wpn4 = 0;
8253 92 tempitem.wpn5 = 0;
8254 92 tempitem.wpn6 = 0;
8255 92 tempitem.wpn7 = 0;
8256 92 tempitem.wpn8 = 0;
8257 92 tempitem.wpn9 = 0;
8258 92 tempitem.wpn10 = 0;
8259 92 break;
8260 }
8261 case itype_bracelet:
8262 {
8263 279 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8264 279 tempitem.misc1 = 0;
8265 279 tempitem.misc2 = 0;
8266 279 tempitem.misc3 = 0;
8267 279 tempitem.misc4 = 0;
8268 279 tempitem.misc5 = 0;
8269 279 tempitem.misc6 = 0;
8270 279 tempitem.misc7 = 0;
8271 279 tempitem.misc8 = 0;
8272 279 tempitem.misc9 = 0;
8273 279 tempitem.misc10 = 0;
8274 279 tempitem.wpn = 0;
8275 279 tempitem.wpn2 = 0;
8276 279 tempitem.wpn3 = 0;
8277 279 tempitem.wpn4 = 0;
8278 279 tempitem.wpn5 = 0;
8279 279 tempitem.wpn6 = 0;
8280 279 tempitem.wpn7 = 0;
8281 279 tempitem.wpn8 = 0;
8282 279 tempitem.wpn9 = 0;
8283 279 tempitem.wpn10 = 0;
8284 279 break;
8285 }
8286 case itype_flippers:
8287 {
8288 93 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8289 93 tempitem.misc1 = 0;
8290 93 tempitem.misc2 = 0;
8291 93 tempitem.misc3 = 0;
8292 93 tempitem.misc4 = 0;
8293 93 tempitem.misc5 = 0;
8294 93 tempitem.misc6 = 0;
8295 93 tempitem.misc7 = 0;
8296 93 tempitem.misc8 = 0;
8297 93 tempitem.misc9 = 0;
8298 93 tempitem.misc10 = 0;
8299 93 tempitem.wpn = 0;
8300 93 tempitem.wpn2 = 0;
8301 93 tempitem.wpn3 = 0;
8302 93 tempitem.wpn4 = 0;
8303 93 tempitem.wpn5 = 0;
8304 93 tempitem.wpn6 = 0;
8305 93 tempitem.wpn7 = 0;
8306 93 tempitem.wpn8 = 0;
8307 93 tempitem.wpn9 = 0;
8308 93 tempitem.wpn10 = 0;
8309 93 break;
8310 }
8311 case itype_boots:
8312 {
8313 94 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8314 94 tempitem.misc1 = 0;
8315 94 tempitem.misc2 = 0;
8316 94 tempitem.misc3 = 0;
8317 94 tempitem.misc4 = 0;
8318 94 tempitem.misc5 = 0;
8319 94 tempitem.misc6 = 0;
8320 94 tempitem.misc7 = 0;
8321 94 tempitem.misc8 = 0;
8322 94 tempitem.misc9 = 0;
8323 94 tempitem.misc10 = 0;
8324 94 tempitem.wpn = 0;
8325 94 tempitem.wpn2 = 0;
8326 94 tempitem.wpn3 = 0;
8327 94 tempitem.wpn4 = 0;
8328 94 tempitem.wpn5 = 0;
8329 94 tempitem.wpn6 = 0;
8330 94 tempitem.wpn7 = 0;
8331 94 tempitem.wpn8 = 0;
8332 94 tempitem.wpn9 = 0;
8333 94 tempitem.wpn10 = 0;
8334 94 break;
8335 }
8336 case itype_hookshot:
8337 {
8338 184 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8339 184 tempitem.misc5 = 0;
8340 184 tempitem.misc6 = 0;
8341 184 tempitem.misc7 = 0;
8342 184 tempitem.misc8 = 0;
8343 184 tempitem.misc9 = 0;
8344 184 tempitem.misc10 = 0;
8345 184 tempitem.wpn5 = 0;
8346 184 tempitem.wpn6 = 0;
8347 184 tempitem.wpn7 = 0;
8348 184 tempitem.wpn8 = 0;
8349 184 tempitem.wpn9 = 0;
8350 184 tempitem.wpn10 = 0;
8351 184 break;
8352 }
8353 case itype_lens:
8354 {
8355 92 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8356 92 tempitem.misc2 = 0;
8357 92 tempitem.misc3 = 0;
8358 92 tempitem.misc4 = 0;
8359 92 tempitem.misc5 = 0;
8360 92 tempitem.misc6 = 0;
8361 92 tempitem.misc7 = 0;
8362 92 tempitem.misc8 = 0;
8363 92 tempitem.misc9 = 0;
8364 92 tempitem.misc10 = 0;
8365 92 tempitem.wpn = 0;
8366 92 tempitem.wpn2 = 0;
8367 92 tempitem.wpn3 = 0;
8368 92 tempitem.wpn4 = 0;
8369 92 tempitem.wpn5 = 0;
8370 92 tempitem.wpn6 = 0;
8371 92 tempitem.wpn7 = 0;
8372 92 tempitem.wpn8 = 0;
8373 92 tempitem.wpn9 = 0;
8374 92 tempitem.wpn10 = 0;
8375 92 break;
8376 }
8377 case itype_hammer:
8378 {
8379 93 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8380 93 tempitem.misc1 = 0;
8381 93 tempitem.misc2 = 0;
8382 93 tempitem.misc3 = 0;
8383 93 tempitem.misc4 = 0;
8384 93 tempitem.misc5 = 0;
8385 93 tempitem.misc6 = 0;
8386 93 tempitem.misc7 = 0;
8387 93 tempitem.misc8 = 0;
8388 93 tempitem.misc9 = 0;
8389 93 tempitem.misc10 = 0;
8390 93 tempitem.wpn3 = 0;
8391 93 tempitem.wpn4 = 0;
8392 93 tempitem.wpn5 = 0;
8393 93 tempitem.wpn6 = 0;
8394 93 tempitem.wpn7 = 0;
8395 93 tempitem.wpn8 = 0;
8396 93 tempitem.wpn9 = 0;
8397 93 tempitem.wpn10 = 0;
8398 93 break;
8399 }
8400 case itype_divinefire:
8401 {
8402 92 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG4 | ITEM_FLAG5);
8403 92 tempitem.misc3 = 0;
8404 92 tempitem.misc4 = 0;
8405 92 tempitem.misc5 = 0;
8406 92 tempitem.misc6 = 0;
8407 92 tempitem.misc7 = 0;
8408 92 tempitem.misc8 = 0;
8409 92 tempitem.misc9 = 0;
8410 92 tempitem.misc10 = 0;
8411 92 tempitem.wpn6 = 0;
8412 92 tempitem.wpn7 = 0;
8413 92 tempitem.wpn8 = 0;
8414 92 tempitem.wpn9 = 0;
8415 92 tempitem.wpn10 = 0;
8416 92 break;
8417 }
8418 case itype_divineescape:
8419 {
8420 92 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8421 92 tempitem.misc2 = 0;
8422 92 tempitem.misc3 = 0;
8423 92 tempitem.misc4 = 0;
8424 92 tempitem.misc5 = 0;
8425 92 tempitem.misc6 = 0;
8426 92 tempitem.misc7 = 0;
8427 92 tempitem.misc8 = 0;
8428 92 tempitem.misc9 = 0;
8429 92 tempitem.misc10 = 0;
8430 92 tempitem.wpn = 0;
8431 92 tempitem.wpn2 = 0;
8432 92 tempitem.wpn3 = 0;
8433 92 tempitem.wpn4 = 0;
8434 92 tempitem.wpn5 = 0;
8435 92 tempitem.wpn6 = 0;
8436 92 tempitem.wpn7 = 0;
8437 92 tempitem.wpn8 = 0;
8438 92 tempitem.wpn9 = 0;
8439 92 tempitem.wpn10 = 0;
8440 92 break;
8441 }
8442 case itype_divineprotection:
8443 {
8444 92 tempitem.flags &= ~ (ITEM_FLAG5);
8445 92 tempitem.misc2 = 0;
8446 92 tempitem.misc3 = 0;
8447 92 tempitem.misc4 = 0;
8448 92 tempitem.misc5 = 0;
8449 92 tempitem.misc6 = 0;
8450 92 tempitem.misc7 = 0;
8451 92 tempitem.misc8 = 0;
8452 92 tempitem.misc9 = 0;
8453 92 tempitem.misc10 = 0;
8454 92 break;
8455 }
8456 case itype_bomb:
8457 {
8458 107 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8459 107 tempitem.misc4 = 0;
8460 107 tempitem.misc5 = 0;
8461 107 tempitem.misc6 = 0;
8462 107 tempitem.misc7 = 0;
8463 107 tempitem.misc8 = 0;
8464 107 tempitem.misc9 = 0;
8465 107 tempitem.misc10 = 0;
8466 107 tempitem.wpn3 = 0;
8467 107 tempitem.wpn4 = 0;
8468 107 tempitem.wpn5 = 0;
8469 107 tempitem.wpn6 = 0;
8470 107 tempitem.wpn7 = 0;
8471 107 tempitem.wpn8 = 0;
8472 107 tempitem.wpn9 = 0;
8473 107 tempitem.wpn10 = 0;
8474 107 break;
8475 }
8476 case itype_sbomb:
8477 {
8478 92 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8479 92 tempitem.misc4 = 0;
8480 92 tempitem.misc5 = 0;
8481 92 tempitem.misc6 = 0;
8482 92 tempitem.misc7 = 0;
8483 92 tempitem.misc8 = 0;
8484 92 tempitem.misc9 = 0;
8485 92 tempitem.misc10 = 0;
8486 92 tempitem.wpn3 = 0;
8487 92 tempitem.wpn4 = 0;
8488 92 tempitem.wpn5 = 0;
8489 92 tempitem.wpn6 = 0;
8490 92 tempitem.wpn7 = 0;
8491 92 tempitem.wpn8 = 0;
8492 92 tempitem.wpn9 = 0;
8493 92 tempitem.wpn10 = 0;
8494 92 break;
8495 }
8496 case itype_clock:
8497 {
8498 93 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8499 93 tempitem.misc2 = 0;
8500 93 tempitem.misc3 = 0;
8501 93 tempitem.misc4 = 0;
8502 93 tempitem.misc5 = 0;
8503 93 tempitem.misc6 = 0;
8504 93 tempitem.misc7 = 0;
8505 93 tempitem.misc8 = 0;
8506 93 tempitem.misc9 = 0;
8507 93 tempitem.misc10 = 0;
8508 93 tempitem.wpn = 0;
8509 93 tempitem.wpn2 = 0;
8510 93 tempitem.wpn3 = 0;
8511 93 tempitem.wpn4 = 0;
8512 93 tempitem.wpn5 = 0;
8513 93 tempitem.wpn6 = 0;
8514 93 tempitem.wpn7 = 0;
8515 93 tempitem.wpn8 = 0;
8516 93 tempitem.wpn9 = 0;
8517 93 tempitem.wpn10 = 0;
8518 93 break;
8519 }
8520 case itype_key:
8521 {
8522 92 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8523 92 tempitem.misc1 = 0;
8524 92 tempitem.misc2 = 0;
8525 92 tempitem.misc3 = 0;
8526 92 tempitem.misc4 = 0;
8527 92 tempitem.misc5 = 0;
8528 92 tempitem.misc6 = 0;
8529 92 tempitem.misc7 = 0;
8530 92 tempitem.misc8 = 0;
8531 92 tempitem.misc9 = 0;
8532 92 tempitem.misc10 = 0;
8533 92 tempitem.wpn = 0;
8534 92 tempitem.wpn2 = 0;
8535 92 tempitem.wpn3 = 0;
8536 92 tempitem.wpn4 = 0;
8537 92 tempitem.wpn5 = 0;
8538 92 tempitem.wpn6 = 0;
8539 92 tempitem.wpn7 = 0;
8540 92 tempitem.wpn8 = 0;
8541 92 tempitem.wpn9 = 0;
8542 92 tempitem.wpn10 = 0;
8543 92 break;
8544 }
8545 case itype_magiccontainer:
8546 {
8547 93 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8548 93 tempitem.misc1 = 0;
8549 93 tempitem.misc2 = 0;
8550 93 tempitem.misc3 = 0;
8551 93 tempitem.misc4 = 0;
8552 93 tempitem.misc5 = 0;
8553 93 tempitem.misc6 = 0;
8554 93 tempitem.misc7 = 0;
8555 93 tempitem.misc8 = 0;
8556 93 tempitem.misc9 = 0;
8557 93 tempitem.misc10 = 0;
8558 93 tempitem.wpn = 0;
8559 93 tempitem.wpn2 = 0;
8560 93 tempitem.wpn3 = 0;
8561 93 tempitem.wpn4 = 0;
8562 93 tempitem.wpn5 = 0;
8563 93 tempitem.wpn6 = 0;
8564 93 tempitem.wpn7 = 0;
8565 93 tempitem.wpn8 = 0;
8566 93 tempitem.wpn9 = 0;
8567 93 tempitem.wpn10 = 0;
8568 93 break;
8569 }
8570 case itype_triforcepiece:
8571 {
8572 184 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8573 184 tempitem.misc3 = 0;
8574 184 tempitem.misc4 = 0;
8575 184 tempitem.misc5 = 0;
8576 184 tempitem.misc6 = 0;
8577 184 tempitem.misc7 = 0;
8578 184 tempitem.misc8 = 0;
8579 184 tempitem.misc9 = 0;
8580 184 tempitem.misc10 = 0;
8581 184 tempitem.wpn = 0;
8582 184 tempitem.wpn2 = 0;
8583 184 tempitem.wpn3 = 0;
8584 184 tempitem.wpn4 = 0;
8585 184 tempitem.wpn5 = 0;
8586 184 tempitem.wpn6 = 0;
8587 184 tempitem.wpn7 = 0;
8588 184 tempitem.wpn8 = 0;
8589 184 tempitem.wpn9 = 0;
8590 184 tempitem.wpn10 = 0;
8591 184 break;
8592 }
8593 case itype_map: case itype_compass: case itype_bosskey:
8594 {
8595 277 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8596 277 tempitem.misc1 = 0;
8597 277 tempitem.misc2 = 0;
8598 277 tempitem.misc3 = 0;
8599 277 tempitem.misc4 = 0;
8600 277 tempitem.misc5 = 0;
8601 277 tempitem.misc6 = 0;
8602 277 tempitem.misc7 = 0;
8603 277 tempitem.misc8 = 0;
8604 277 tempitem.misc9 = 0;
8605 277 tempitem.misc10 = 0;
8606 277 tempitem.wpn = 0;
8607 277 tempitem.wpn2 = 0;
8608 277 tempitem.wpn3 = 0;
8609 277 tempitem.wpn4 = 0;
8610 277 tempitem.wpn5 = 0;
8611 277 tempitem.wpn6 = 0;
8612 277 tempitem.wpn7 = 0;
8613 277 tempitem.wpn8 = 0;
8614 277 tempitem.wpn9 = 0;
8615 277 tempitem.wpn10 = 0;
8616 277 break;
8617 }
8618 case itype_quiver:
8619 {
8620 368 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8621 368 tempitem.misc3 = 0;
8622 368 tempitem.misc4 = 0;
8623 368 tempitem.misc5 = 0;
8624 368 tempitem.misc6 = 0;
8625 368 tempitem.misc7 = 0;
8626 368 tempitem.misc8 = 0;
8627 368 tempitem.misc9 = 0;
8628 368 tempitem.misc10 = 0;
8629 368 tempitem.wpn = 0;
8630 368 tempitem.wpn2 = 0;
8631 368 tempitem.wpn3 = 0;
8632 368 tempitem.wpn4 = 0;
8633 368 tempitem.wpn5 = 0;
8634 368 tempitem.wpn6 = 0;
8635 368 tempitem.wpn7 = 0;
8636 368 tempitem.wpn8 = 0;
8637 368 tempitem.wpn9 = 0;
8638 368 tempitem.wpn10 = 0;
8639 368 break;
8640 }
8641 case itype_lkey:
8642 {
8643 94 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8644 94 tempitem.misc1 = 0;
8645 94 tempitem.misc2 = 0;
8646 94 tempitem.misc3 = 0;
8647 94 tempitem.misc4 = 0;
8648 94 tempitem.misc5 = 0;
8649 94 tempitem.misc6 = 0;
8650 94 tempitem.misc7 = 0;
8651 94 tempitem.misc8 = 0;
8652 94 tempitem.misc9 = 0;
8653 94 tempitem.misc10 = 0;
8654 94 tempitem.wpn = 0;
8655 94 tempitem.wpn2 = 0;
8656 94 tempitem.wpn3 = 0;
8657 94 tempitem.wpn4 = 0;
8658 94 tempitem.wpn5 = 0;
8659 94 tempitem.wpn6 = 0;
8660 94 tempitem.wpn7 = 0;
8661 94 tempitem.wpn8 = 0;
8662 94 tempitem.wpn9 = 0;
8663 94 tempitem.wpn10 = 0;
8664 94 break;
8665 }
8666 case itype_cbyrna:
8667 {
8668 92 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG5);
8669 92 tempitem.misc4 = 0;
8670 92 tempitem.misc5 = 0;
8671 92 tempitem.misc6 = 0;
8672 92 tempitem.misc7 = 0;
8673 92 tempitem.misc8 = 0;
8674 92 tempitem.misc9 = 0;
8675 92 tempitem.misc10 = 0;
8676 92 tempitem.wpn6 = 0;
8677 92 tempitem.wpn7 = 0;
8678 92 tempitem.wpn8 = 0;
8679 92 tempitem.wpn9 = 0;
8680 92 tempitem.wpn10 = 0;
8681 92 break;
8682 }
8683 case itype_rupee: case itype_arrowammo:
8684 {
8685 1135 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8686 1135 tempitem.misc1 = 0;
8687 1135 tempitem.misc2 = 0;
8688 1135 tempitem.misc3 = 0;
8689 1135 tempitem.misc4 = 0;
8690 1135 tempitem.misc5 = 0;
8691 1135 tempitem.misc6 = 0;
8692 1135 tempitem.misc7 = 0;
8693 1135 tempitem.misc8 = 0;
8694 1135 tempitem.misc9 = 0;
8695 1135 tempitem.misc10 = 0;
8696 1135 tempitem.wpn = 0;
8697 1135 tempitem.wpn2 = 0;
8698 1135 tempitem.wpn3 = 0;
8699 1135 tempitem.wpn4 = 0;
8700 1135 tempitem.wpn5 = 0;
8701 1135 tempitem.wpn6 = 0;
8702 1135 tempitem.wpn7 = 0;
8703 1135 tempitem.wpn8 = 0;
8704 1135 tempitem.wpn9 = 0;
8705 1135 tempitem.wpn10 = 0;
8706 1135 break;
8707 }
8708 case itype_fairy:
8709 {
8710 168 tempitem.flags &= ~ (ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8711 168 tempitem.misc4 = 0;
8712 168 tempitem.misc5 = 0;
8713 168 tempitem.misc6 = 0;
8714 168 tempitem.misc7 = 0;
8715 168 tempitem.misc8 = 0;
8716 168 tempitem.misc9 = 0;
8717 168 tempitem.misc10 = 0;
8718 168 tempitem.wpn = 0;
8719 168 tempitem.wpn2 = 0;
8720 168 tempitem.wpn3 = 0;
8721 168 tempitem.wpn4 = 0;
8722 168 tempitem.wpn5 = 0;
8723 168 tempitem.wpn6 = 0;
8724 168 tempitem.wpn7 = 0;
8725 168 tempitem.wpn8 = 0;
8726 168 tempitem.wpn9 = 0;
8727 168 tempitem.wpn10 = 0;
8728 168 break;
8729 }
8730 case itype_magic: case itype_heart: case itype_heartcontainer: case itype_heartpiece: case itype_killem: case itype_bombammo:
8731 {
8732 983 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8733 983 tempitem.misc1 = 0;
8734 983 tempitem.misc2 = 0;
8735 983 tempitem.misc3 = 0;
8736 983 tempitem.misc4 = 0;
8737 983 tempitem.misc5 = 0;
8738 983 tempitem.misc6 = 0;
8739 983 tempitem.misc7 = 0;
8740 983 tempitem.misc8 = 0;
8741 983 tempitem.misc9 = 0;
8742 983 tempitem.misc10 = 0;
8743 983 tempitem.wpn = 0;
8744 983 tempitem.wpn2 = 0;
8745 983 tempitem.wpn3 = 0;
8746 983 tempitem.wpn4 = 0;
8747 983 tempitem.wpn5 = 0;
8748 983 tempitem.wpn6 = 0;
8749 983 tempitem.wpn7 = 0;
8750 983 tempitem.wpn8 = 0;
8751 983 tempitem.wpn9 = 0;
8752 983 tempitem.wpn10 = 0;
8753 983 break;
8754 }
8755 case itype_bombbag:
8756 {
8757 368 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8758 368 tempitem.misc3 = 0;
8759 368 tempitem.misc4 = 0;
8760 368 tempitem.misc5 = 0;
8761 368 tempitem.misc6 = 0;
8762 368 tempitem.misc7 = 0;
8763 368 tempitem.misc8 = 0;
8764 368 tempitem.misc9 = 0;
8765 368 tempitem.misc10 = 0;
8766 368 tempitem.wpn = 0;
8767 368 tempitem.wpn2 = 0;
8768 368 tempitem.wpn3 = 0;
8769 368 tempitem.wpn4 = 0;
8770 368 tempitem.wpn5 = 0;
8771 368 tempitem.wpn6 = 0;
8772 368 tempitem.wpn7 = 0;
8773 368 tempitem.wpn8 = 0;
8774 368 tempitem.wpn9 = 0;
8775 368 tempitem.wpn10 = 0;
8776 368 break;
8777 }
8778 case itype_rocs:
8779 {
8780 92 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8781 92 tempitem.misc1 = 0;
8782 92 tempitem.misc2 = 0;
8783 92 tempitem.misc3 = 0;
8784 92 tempitem.misc4 = 0;
8785 92 tempitem.misc5 = 0;
8786 92 tempitem.misc6 = 0;
8787 92 tempitem.misc7 = 0;
8788 92 tempitem.misc8 = 0;
8789 92 tempitem.misc9 = 0;
8790 92 tempitem.misc10 = 0;
8791 92 tempitem.wpn = 0;
8792 92 tempitem.wpn2 = 0;
8793 92 tempitem.wpn3 = 0;
8794 92 tempitem.wpn4 = 0;
8795 92 tempitem.wpn5 = 0;
8796 92 tempitem.wpn6 = 0;
8797 92 tempitem.wpn7 = 0;
8798 92 tempitem.wpn8 = 0;
8799 92 tempitem.wpn9 = 0;
8800 92 tempitem.wpn10 = 0;
8801 92 break;
8802 }
8803 case itype_hoverboots:
8804 {
8805 92 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8806 92 tempitem.misc2 = 0;
8807 92 tempitem.misc3 = 0;
8808 92 tempitem.misc4 = 0;
8809 92 tempitem.misc5 = 0;
8810 92 tempitem.misc6 = 0;
8811 92 tempitem.misc7 = 0;
8812 92 tempitem.misc8 = 0;
8813 92 tempitem.misc9 = 0;
8814 92 tempitem.misc10 = 0;
8815 92 tempitem.wpn2 = 0;
8816 92 tempitem.wpn3 = 0;
8817 92 tempitem.wpn4 = 0;
8818 92 tempitem.wpn5 = 0;
8819 92 tempitem.wpn6 = 0;
8820 92 tempitem.wpn7 = 0;
8821 92 tempitem.wpn8 = 0;
8822 92 tempitem.wpn9 = 0;
8823 92 tempitem.wpn10 = 0;
8824 92 break;
8825 }
8826 case itype_spinscroll:
8827 {
8828 92 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8829 92 tempitem.misc2 = 0;
8830 92 tempitem.misc3 = 0;
8831 92 tempitem.misc4 = 0;
8832 92 tempitem.misc5 = 0;
8833 92 tempitem.misc6 = 0;
8834 92 tempitem.misc7 = 0;
8835 92 tempitem.misc8 = 0;
8836 92 tempitem.misc9 = 0;
8837 92 tempitem.misc10 = 0;
8838 92 tempitem.wpn = 0;
8839 92 tempitem.wpn2 = 0;
8840 92 tempitem.wpn3 = 0;
8841 92 tempitem.wpn4 = 0;
8842 92 tempitem.wpn5 = 0;
8843 92 tempitem.wpn6 = 0;
8844 92 tempitem.wpn7 = 0;
8845 92 tempitem.wpn8 = 0;
8846 92 tempitem.wpn9 = 0;
8847 92 tempitem.wpn10 = 0;
8848 92 break;
8849 }
8850 case itype_crossscroll:
8851 {
8852 92 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8853 92 tempitem.misc1 = 0;
8854 92 tempitem.misc2 = 0;
8855 92 tempitem.misc3 = 0;
8856 92 tempitem.misc4 = 0;
8857 92 tempitem.misc5 = 0;
8858 92 tempitem.misc6 = 0;
8859 92 tempitem.misc7 = 0;
8860 92 tempitem.misc8 = 0;
8861 92 tempitem.misc9 = 0;
8862 92 tempitem.misc10 = 0;
8863 92 tempitem.wpn = 0;
8864 92 tempitem.wpn2 = 0;
8865 92 tempitem.wpn3 = 0;
8866 92 tempitem.wpn4 = 0;
8867 92 tempitem.wpn5 = 0;
8868 92 tempitem.wpn6 = 0;
8869 92 tempitem.wpn7 = 0;
8870 92 tempitem.wpn8 = 0;
8871 92 tempitem.wpn9 = 0;
8872 92 tempitem.wpn10 = 0;
8873 92 break;
8874 }
8875 case itype_quakescroll:
8876 {
8877 92 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8878 92 tempitem.misc3 = 0;
8879 92 tempitem.misc4 = 0;
8880 92 tempitem.misc5 = 0;
8881 92 tempitem.misc6 = 0;
8882 92 tempitem.misc7 = 0;
8883 92 tempitem.misc8 = 0;
8884 92 tempitem.misc9 = 0;
8885 92 tempitem.misc10 = 0;
8886 92 tempitem.wpn = 0;
8887 92 tempitem.wpn2 = 0;
8888 92 tempitem.wpn3 = 0;
8889 92 tempitem.wpn4 = 0;
8890 92 tempitem.wpn5 = 0;
8891 92 tempitem.wpn6 = 0;
8892 92 tempitem.wpn7 = 0;
8893 92 tempitem.wpn8 = 0;
8894 92 tempitem.wpn9 = 0;
8895 92 tempitem.wpn10 = 0;
8896 92 break;
8897 }
8898 case itype_whispring:
8899 {
8900 185 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8901 185 tempitem.misc2 = 0;
8902 185 tempitem.misc3 = 0;
8903 185 tempitem.misc4 = 0;
8904 185 tempitem.misc5 = 0;
8905 185 tempitem.misc6 = 0;
8906 185 tempitem.misc7 = 0;
8907 185 tempitem.misc8 = 0;
8908 185 tempitem.misc9 = 0;
8909 185 tempitem.misc10 = 0;
8910 185 tempitem.wpn = 0;
8911 185 tempitem.wpn2 = 0;
8912 185 tempitem.wpn3 = 0;
8913 185 tempitem.wpn4 = 0;
8914 185 tempitem.wpn5 = 0;
8915 185 tempitem.wpn6 = 0;
8916 185 tempitem.wpn7 = 0;
8917 185 tempitem.wpn8 = 0;
8918 185 tempitem.wpn9 = 0;
8919 185 tempitem.wpn10 = 0;
8920 185 break;
8921 }
8922 case itype_chargering:
8923 {
8924 184 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8925 184 tempitem.misc3 = 0;
8926 184 tempitem.misc4 = 0;
8927 184 tempitem.misc5 = 0;
8928 184 tempitem.misc6 = 0;
8929 184 tempitem.misc7 = 0;
8930 184 tempitem.misc8 = 0;
8931 184 tempitem.misc9 = 0;
8932 184 tempitem.misc10 = 0;
8933 184 tempitem.wpn = 0;
8934 184 tempitem.wpn2 = 0;
8935 184 tempitem.wpn3 = 0;
8936 184 tempitem.wpn4 = 0;
8937 184 tempitem.wpn5 = 0;
8938 184 tempitem.wpn6 = 0;
8939 184 tempitem.wpn7 = 0;
8940 184 tempitem.wpn8 = 0;
8941 184 tempitem.wpn9 = 0;
8942 184 tempitem.wpn10 = 0;
8943 184 break;
8944 }
8945 case itype_perilscroll:
8946 {
8947 92 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8948 92 tempitem.misc2 = 0;
8949 92 tempitem.misc3 = 0;
8950 92 tempitem.misc4 = 0;
8951 92 tempitem.misc5 = 0;
8952 92 tempitem.misc6 = 0;
8953 92 tempitem.misc7 = 0;
8954 92 tempitem.misc8 = 0;
8955 92 tempitem.misc9 = 0;
8956 92 tempitem.misc10 = 0;
8957 92 tempitem.wpn = 0;
8958 92 tempitem.wpn2 = 0;
8959 92 tempitem.wpn3 = 0;
8960 92 tempitem.wpn4 = 0;
8961 92 tempitem.wpn5 = 0;
8962 92 tempitem.wpn6 = 0;
8963 92 tempitem.wpn7 = 0;
8964 92 tempitem.wpn8 = 0;
8965 92 tempitem.wpn9 = 0;
8966 92 tempitem.wpn10 = 0;
8967 92 break;
8968 }
8969 case itype_wealthmedal:
8970 {
8971 277 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8972 277 tempitem.misc2 = 0;
8973 277 tempitem.misc3 = 0;
8974 277 tempitem.misc4 = 0;
8975 277 tempitem.misc5 = 0;
8976 277 tempitem.misc6 = 0;
8977 277 tempitem.misc7 = 0;
8978 277 tempitem.misc8 = 0;
8979 277 tempitem.misc9 = 0;
8980 277 tempitem.misc10 = 0;
8981 277 tempitem.wpn = 0;
8982 277 tempitem.wpn2 = 0;
8983 277 tempitem.wpn3 = 0;
8984 277 tempitem.wpn4 = 0;
8985 277 tempitem.wpn5 = 0;
8986 277 tempitem.wpn6 = 0;
8987 277 tempitem.wpn7 = 0;
8988 277 tempitem.wpn8 = 0;
8989 277 tempitem.wpn9 = 0;
8990 277 tempitem.wpn10 = 0;
8991 277 break;
8992 }
8993 case itype_heartring:
8994 {
8995 278 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8996 278 tempitem.misc3 = 0;
8997 278 tempitem.misc4 = 0;
8998 278 tempitem.misc5 = 0;
8999 278 tempitem.misc6 = 0;
9000 278 tempitem.misc7 = 0;
9001 278 tempitem.misc8 = 0;
9002 278 tempitem.misc9 = 0;
9003 278 tempitem.misc10 = 0;
9004 278 tempitem.wpn = 0;
9005 278 tempitem.wpn2 = 0;
9006 278 tempitem.wpn3 = 0;
9007 278 tempitem.wpn4 = 0;
9008 278 tempitem.wpn5 = 0;
9009 278 tempitem.wpn6 = 0;
9010 278 tempitem.wpn7 = 0;
9011 278 tempitem.wpn8 = 0;
9012 278 tempitem.wpn9 = 0;
9013 278 tempitem.wpn10 = 0;
9014 278 break;
9015 }
9016 case itype_magicring:
9017 {
9018 372 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
9019 372 tempitem.misc3 = 0;
9020 372 tempitem.misc4 = 0;
9021 372 tempitem.misc5 = 0;
9022 372 tempitem.misc6 = 0;
9023 372 tempitem.misc7 = 0;
9024 372 tempitem.misc8 = 0;
9025 372 tempitem.misc9 = 0;
9026 372 tempitem.misc10 = 0;
9027 372 tempitem.wpn = 0;
9028 372 tempitem.wpn2 = 0;
9029 372 tempitem.wpn3 = 0;
9030 372 tempitem.wpn4 = 0;
9031 372 tempitem.wpn5 = 0;
9032 372 tempitem.wpn6 = 0;
9033 372 tempitem.wpn7 = 0;
9034 372 tempitem.wpn8 = 0;
9035 372 tempitem.wpn9 = 0;
9036 372 tempitem.wpn10 = 0;
9037 372 break;
9038 }
9039 case itype_spinscroll2:
9040 {
9041 92 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
9042 92 tempitem.misc2 = 0;
9043 92 tempitem.misc3 = 0;
9044 92 tempitem.misc4 = 0;
9045 92 tempitem.misc5 = 0;
9046 92 tempitem.misc6 = 0;
9047 92 tempitem.misc7 = 0;
9048 92 tempitem.misc8 = 0;
9049 92 tempitem.misc9 = 0;
9050 92 tempitem.misc10 = 0;
9051 92 tempitem.wpn = 0;
9052 92 tempitem.wpn2 = 0;
9053 92 tempitem.wpn3 = 0;
9054 92 tempitem.wpn4 = 0;
9055 92 tempitem.wpn5 = 0;
9056 92 tempitem.wpn6 = 0;
9057 92 tempitem.wpn7 = 0;
9058 92 tempitem.wpn8 = 0;
9059 92 tempitem.wpn9 = 0;
9060 92 tempitem.wpn10 = 0;
9061 92 break;
9062 }
9063 case itype_quakescroll2:
9064 {
9065 92 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
9066 92 tempitem.misc3 = 0;
9067 92 tempitem.misc4 = 0;
9068 92 tempitem.misc5 = 0;
9069 92 tempitem.misc6 = 0;
9070 92 tempitem.misc7 = 0;
9071 92 tempitem.misc8 = 0;
9072 92 tempitem.misc9 = 0;
9073 92 tempitem.misc10 = 0;
9074 92 tempitem.wpn = 0;
9075 92 tempitem.wpn2 = 0;
9076 92 tempitem.wpn3 = 0;
9077 92 tempitem.wpn4 = 0;
9078 92 tempitem.wpn5 = 0;
9079 92 tempitem.wpn6 = 0;
9080 92 tempitem.wpn7 = 0;
9081 92 tempitem.wpn8 = 0;
9082 92 tempitem.wpn9 = 0;
9083 92 tempitem.wpn10 = 0;
9084 92 break;
9085 }
9086 case itype_agony:
9087 {
9088 92 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
9089 92 tempitem.misc2 = 0;
9090 92 tempitem.misc3 = 0;
9091 92 tempitem.misc4 = 0;
9092 92 tempitem.misc5 = 0;
9093 92 tempitem.misc6 = 0;
9094 92 tempitem.misc7 = 0;
9095 92 tempitem.misc8 = 0;
9096 92 tempitem.misc9 = 0;
9097 92 tempitem.misc10 = 0;
9098 92 tempitem.wpn = 0;
9099 92 tempitem.wpn2 = 0;
9100 92 tempitem.wpn3 = 0;
9101 92 tempitem.wpn4 = 0;
9102 92 tempitem.wpn5 = 0;
9103 92 tempitem.wpn6 = 0;
9104 92 tempitem.wpn7 = 0;
9105 92 tempitem.wpn8 = 0;
9106 92 tempitem.wpn9 = 0;
9107 92 tempitem.wpn10 = 0;
9108 92 break;
9109 }
9110 case itype_stompboots:
9111 {
9112 92 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
9113 92 tempitem.misc1 = 0;
9114 92 tempitem.misc2 = 0;
9115 92 tempitem.misc3 = 0;
9116 92 tempitem.misc4 = 0;
9117 92 tempitem.misc5 = 0;
9118 92 tempitem.misc6 = 0;
9119 92 tempitem.misc7 = 0;
9120 92 tempitem.misc8 = 0;
9121 92 tempitem.misc9 = 0;
9122 92 tempitem.misc10 = 0;
9123 92 tempitem.wpn = 0;
9124 92 tempitem.wpn2 = 0;
9125 92 tempitem.wpn3 = 0;
9126 92 tempitem.wpn4 = 0;
9127 92 tempitem.wpn5 = 0;
9128 92 tempitem.wpn6 = 0;
9129 92 tempitem.wpn7 = 0;
9130 92 tempitem.wpn8 = 0;
9131 92 tempitem.wpn9 = 0;
9132 92 tempitem.wpn10 = 0;
9133 92 break;
9134 }
9135 case itype_whimsicalring:
9136 {
9137 92 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
9138 92 tempitem.misc2 = 0;
9139 92 tempitem.misc3 = 0;
9140 92 tempitem.misc4 = 0;
9141 92 tempitem.misc5 = 0;
9142 92 tempitem.misc6 = 0;
9143 92 tempitem.misc7 = 0;
9144 92 tempitem.misc8 = 0;
9145 92 tempitem.misc9 = 0;
9146 92 tempitem.misc10 = 0;
9147 92 tempitem.wpn = 0;
9148 92 tempitem.wpn2 = 0;
9149 92 tempitem.wpn3 = 0;
9150 92 tempitem.wpn4 = 0;
9151 92 tempitem.wpn5 = 0;
9152 92 tempitem.wpn6 = 0;
9153 92 tempitem.wpn7 = 0;
9154 92 tempitem.wpn8 = 0;
9155 92 tempitem.wpn9 = 0;
9156 92 tempitem.wpn10 = 0;
9157 92 break;
9158 }
9159 case itype_perilring:
9160 {
9161 93 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
9162 93 tempitem.misc2 = 0;
9163 93 tempitem.misc3 = 0;
9164 93 tempitem.misc4 = 0;
9165 93 tempitem.misc5 = 0;
9166 93 tempitem.misc6 = 0;
9167 93 tempitem.misc7 = 0;
9168 93 tempitem.misc8 = 0;
9169 93 tempitem.misc9 = 0;
9170 93 tempitem.misc10 = 0;
9171 93 tempitem.wpn = 0;
9172 93 tempitem.wpn2 = 0;
9173 93 tempitem.wpn3 = 0;
9174 93 tempitem.wpn4 = 0;
9175 93 tempitem.wpn5 = 0;
9176 93 tempitem.wpn6 = 0;
9177 93 tempitem.wpn7 = 0;
9178 93 tempitem.wpn8 = 0;
9179 93 tempitem.wpn9 = 0;
9180 93 tempitem.wpn10 = 0;
9181 93 break;
9182 }
9183 case itype_custom1: case itype_custom2: case itype_custom3: case itype_custom4: case itype_custom5:
9184 case itype_custom6: case itype_custom7: case itype_custom8: case itype_custom9: case itype_custom10:
9185 case itype_custom11: case itype_custom12: case itype_custom13: case itype_custom14: case itype_custom15:
9186 case itype_custom16: case itype_custom17: case itype_custom18: case itype_custom19: case itype_custom20:
9187 case itype_bowandarrow: case itype_letterpotion: case itype_misc:
9188 {
9189 2541 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
9190 2541 tempitem.misc1 = 0;
9191 2541 tempitem.misc2 = 0;
9192 2541 tempitem.misc3 = 0;
9193 2541 tempitem.misc4 = 0;
9194 2541 tempitem.misc5 = 0;
9195 2541 tempitem.misc6 = 0;
9196 2541 tempitem.misc7 = 0;
9197 2541 tempitem.misc8 = 0;
9198 2541 tempitem.misc9 = 0;
9199 2541 tempitem.misc10 = 0;
9200 2541 tempitem.wpn = 0;
9201 2541 tempitem.wpn2 = 0;
9202 2541 tempitem.wpn3 = 0;
9203 2541 tempitem.wpn4 = 0;
9204 2541 tempitem.wpn5 = 0;
9205 2541 tempitem.wpn6 = 0;
9206 2541 tempitem.wpn7 = 0;
9207 2541 tempitem.wpn8 = 0;
9208 2541 tempitem.wpn9 = 0;
9209 2541 tempitem.wpn10 = 0;
9210 2541 break;
9211 }
9212 }
9213 23808 }
9214 //Port quest rules to items
9215
2/2
✓ Branch 0 taken 8960 times.
✓ Branch 1 taken 23808 times.
32768 if( s_version <= 31)
9216 {
9217
2/2
✓ Branch 0 taken 107 times.
✓ Branch 1 taken 23701 times.
23808 if(tempitem.family == itype_bomb)
9218 {
9219
2/2
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 90 times.
107 if ( get_qr(qr_OUCHBOMBS) ) tempitem.flags |= ITEM_FLAG2;
9220 90 else tempitem.flags &= ~ ITEM_FLAG2;
9221 107 }
9222
2/2
✓ Branch 0 taken 92 times.
✓ Branch 1 taken 23609 times.
23701 else if(tempitem.family == itype_sbomb)
9223 {
9224
2/2
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 75 times.
92 if ( get_qr(qr_OUCHBOMBS) ) tempitem.flags |= ITEM_FLAG2;
9225 75 else tempitem.flags &= ~ ITEM_FLAG2;
9226 92 }
9227
9228
2/2
✓ Branch 0 taken 277 times.
✓ Branch 1 taken 23332 times.
23609 else if(tempitem.family == itype_brang)
9229 {
9230
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 277 times.
277 if ( get_qr(qr_BRANGPICKUP) ) tempitem.flags |= ITEM_FLAG4;
9231 277 else tempitem.flags &= ~ ITEM_FLAG4;
9232 277 }
9233
2/2
✓ Branch 0 taken 23225 times.
✓ Branch 1 taken 107 times.
23332 else if(tempitem.family == itype_wand)
9234 {
9235
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 105 times.
107 if ( get_qr(qr_NOWANDMELEE) ) tempitem.flags |= ITEM_FLAG3;
9236 105 else tempitem.flags &= ~ ITEM_FLAG3;
9237 107 }
9238 23808 }
9239
9240 //Port quest rules to items
9241
2/2
✓ Branch 0 taken 8960 times.
✓ Branch 1 taken 23808 times.
32768 if( s_version <= 37)
9242 {
9243
2/2
✓ Branch 0 taken 93 times.
✓ Branch 1 taken 23715 times.
23808 if(tempitem.family == itype_flippers)
9244 {
9245
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 93 times.
93 if ( (get_qr(qr_NODIVING)) ) tempitem.flags |= ITEM_FLAG1;
9246 93 else tempitem.flags &= ~ ITEM_FLAG1;
9247 93 }
9248
2/2
✓ Branch 0 taken 15904 times.
✓ Branch 1 taken 7811 times.
23715 else if(tempitem.family == itype_sword)
9249 {
9250
2/2
✓ Branch 0 taken 69 times.
✓ Branch 1 taken 7742 times.
7811 if ( (get_qr(qr_QUICKSWORD)) ) tempitem.flags |= ITEM_FLAG5;
9251 7742 else tempitem.flags &= ~ ITEM_FLAG5;
9252 7811 }
9253
2/2
✓ Branch 0 taken 107 times.
✓ Branch 1 taken 15797 times.
15904 else if(tempitem.family == itype_wand)
9254 {
9255
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 104 times.
107 if ( (get_qr(qr_QUICKSWORD)) ) tempitem.flags |= ITEM_FLAG5;
9256 104 else tempitem.flags &= ~ ITEM_FLAG5;
9257 107 }
9258
4/4
✓ Branch 0 taken 15690 times.
✓ Branch 1 taken 107 times.
✓ Branch 2 taken 222 times.
✓ Branch 3 taken 15468 times.
15797 else if(tempitem.family == itype_book || tempitem.family == itype_candle)
9259 {
9260 //@Emily: What was qrFIREPROOFHERO2 again, and does that also need to enable this?
9261
2/2
✓ Branch 0 taken 72 times.
✓ Branch 1 taken 257 times.
329 if ( (get_qr(qr_FIREPROOFHERO)) ) tempitem.flags |= ITEM_FLAG3;
9262 257 else tempitem.flags &= ~ ITEM_FLAG3;
9263 329 }
9264 23808 }
9265
9266
2/2
✓ Branch 0 taken 8960 times.
✓ Branch 1 taken 23808 times.
32768 if( s_version < 38)
9267 {
9268
4/4
✓ Branch 0 taken 23531 times.
✓ Branch 1 taken 277 times.
✓ Branch 2 taken 184 times.
✓ Branch 3 taken 23347 times.
23808 if(tempitem.family == itype_brang || tempitem.family == itype_hookshot)
9269 {
9270
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 461 times.
461 if(get_qr(qr_BRANGPICKUP)) tempitem.flags |= ITEM_FLAG4;
9271 461 else tempitem.flags &= ~ITEM_FLAG4;
9272
9273
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 450 times.
461 if(get_qr(qr_Z3BRANG_HSHOT)) tempitem.flags |= ITEM_FLAG5 | ITEM_FLAG6;
9274 450 else tempitem.flags &= ~(ITEM_FLAG5|ITEM_FLAG6);
9275 461 }
9276
2/2
✓ Branch 0 taken 23073 times.
✓ Branch 1 taken 274 times.
23347 else if(tempitem.family == itype_arrow)
9277 {
9278
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 274 times.
274 if(get_qr(qr_BRANGPICKUP)) tempitem.flags |= ITEM_FLAG4;
9279 274 else tempitem.flags &= ~ITEM_FLAG4;
9280
9281
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 270 times.
274 if(get_qr(qr_Z3BRANG_HSHOT)) tempitem.flags &= ~ITEM_FLAG2;
9282 270 else tempitem.flags |= ITEM_FLAG2;
9283 274 }
9284 23808 }
9285
9286
2/2
✓ Branch 0 taken 8960 times.
✓ Branch 1 taken 23808 times.
32768 if( s_version < 39)
9287 {
9288
6/6
✓ Branch 0 taken 23716 times.
✓ Branch 1 taken 92 times.
✓ Branch 2 taken 23609 times.
✓ Branch 3 taken 107 times.
✓ Branch 4 taken 222 times.
✓ Branch 5 taken 23387 times.
23808 if(tempitem.family == itype_divinefire || tempitem.family == itype_book || tempitem.family == itype_candle)
9289 {
9290
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 409 times.
421 if(get_qr(qr_TEMPCANDLELIGHT)) tempitem.flags |= ITEM_FLAG5;
9291 409 else tempitem.flags &= ~ITEM_FLAG5;
9292 421 }
9293
2/2
✓ Branch 0 taken 183 times.
✓ Branch 1 taken 23204 times.
23387 else if(tempitem.family == itype_potion)
9294 {
9295
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 159 times.
183 if(get_qr(qr_NONBUBBLEMEDICINE))
9296 {
9297 24 tempitem.flags &= ~(ITEM_FLAG3|ITEM_FLAG4);
9298 24 }
9299 else
9300 {
9301 159 tempitem.flags |= ITEM_FLAG3;
9302
2/2
✓ Branch 0 taken 85 times.
✓ Branch 1 taken 74 times.
159 if(get_qr(qr_ITEMBUBBLE))tempitem.flags |= ITEM_FLAG4;
9303 74 else tempitem.flags &= ~ITEM_FLAG4;
9304 }
9305 183 }
9306
2/2
✓ Branch 0 taken 23020 times.
✓ Branch 1 taken 184 times.
23204 else if(tempitem.family == itype_triforcepiece)
9307 {
9308
2/2
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 154 times.
184 if(get_qr(qr_NONBUBBLETRIFORCE))
9309 {
9310 30 tempitem.flags |= ITEM_FLAG3;
9311
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 24 times.
30 if(get_qr(qr_ITEMBUBBLE))tempitem.flags |= ITEM_FLAG4;
9312 24 else tempitem.flags &= ~ITEM_FLAG4;
9313 30 }
9314 else
9315 {
9316 154 tempitem.flags &= ~(ITEM_FLAG3|ITEM_FLAG4);
9317 }
9318 184 }
9319 23808 }
9320
9321
2/2
✓ Branch 0 taken 8960 times.
✓ Branch 1 taken 23808 times.
32768 if( s_version < 40)
9322 {
9323
4/4
✓ Branch 0 taken 23506 times.
✓ Branch 1 taken 302 times.
✓ Branch 2 taken 93 times.
✓ Branch 3 taken 23413 times.
23808 if(tempitem.family == itype_ring || tempitem.family == itype_perilring)
9324 {
9325
2/2
✓ Branch 0 taken 47 times.
✓ Branch 1 taken 348 times.
395 if(get_qr(qr_RINGAFFECTDAMAGE))tempitem.flags |= ITEM_FLAG1;
9326 348 else tempitem.flags &= ~ITEM_FLAG1;
9327 395 }
9328
8/8
✓ Branch 0 taken 23191 times.
✓ Branch 1 taken 222 times.
✓ Branch 2 taken 15380 times.
✓ Branch 3 taken 7811 times.
✓ Branch 4 taken 15273 times.
✓ Branch 5 taken 107 times.
✓ Branch 6 taken 92 times.
✓ Branch 7 taken 15181 times.
23413 else if(tempitem.family == itype_candle || tempitem.family == itype_sword || tempitem.family == itype_wand || tempitem.family == itype_cbyrna)
9329 {
9330
2/2
✓ Branch 0 taken 81 times.
✓ Branch 1 taken 8151 times.
8232 if(get_qr(qr_SLASHFLIPFIX))tempitem.flags |= ITEM_FLAG8;
9331 8151 else tempitem.flags &= ~ITEM_FLAG8;
9332 8232 }
9333
6/6
✓ Branch 0 taken 15997 times.
✓ Branch 1 taken 7811 times.
✓ Branch 2 taken 15890 times.
✓ Branch 3 taken 107 times.
✓ Branch 4 taken 93 times.
✓ Branch 5 taken 15797 times.
23808 if(tempitem.family == itype_sword || tempitem.family == itype_wand || tempitem.family == itype_hammer)
9334 {
9335
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8011 times.
8011 if(get_qr(qr_NOITEMMELEE))tempitem.flags |= ITEM_FLAG7;
9336 8011 else tempitem.flags &= ~ITEM_FLAG7;
9337 8011 }
9338
2/2
✓ Branch 0 taken 15705 times.
✓ Branch 1 taken 92 times.
15797 else if(tempitem.family == itype_cbyrna)
9339 {
9340 92 tempitem.flags |= ITEM_FLAG7;
9341 92 }
9342 23808 }
9343
9344
2/2
✓ Branch 0 taken 8960 times.
✓ Branch 1 taken 23808 times.
32768 if( s_version < 41 )
9345 {
9346
2/2
✓ Branch 0 taken 15997 times.
✓ Branch 1 taken 7811 times.
23808 if(tempitem.family == itype_sword)
9347 {
9348
2/2
✓ Branch 0 taken 69 times.
✓ Branch 1 taken 7742 times.
7811 if(get_qr(qr_SWORDMIRROR))tempitem.flags |= ITEM_FLAG9;
9349 7742 else tempitem.flags &= ~ITEM_FLAG9;
9350
9351
2/2
✓ Branch 0 taken 69 times.
✓ Branch 1 taken 7742 times.
7811 if(get_qr(qr_SLOWCHARGINGWALK))tempitem.flags |= ITEM_FLAG10;
9352 7742 else tempitem.flags &= ~ITEM_FLAG10;
9353 7811 }
9354 23808 }
9355
9356
2/2
✓ Branch 0 taken 8960 times.
✓ Branch 1 taken 23808 times.
32768 if( s_version < 42 )
9357 {
9358
2/2
✓ Branch 0 taken 107 times.
✓ Branch 1 taken 23701 times.
23808 if(tempitem.family == itype_wand)
9359 {
9360
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 105 times.
107 if(get_qr(qr_NOWANDMELEE))tempitem.flags |= ITEM_FLAG3;
9361 105 else tempitem.flags &= ~ITEM_FLAG3;
9362
9363 107 tempitem.flags &= ~ITEM_FLAG6;
9364 107 }
9365
2/2
✓ Branch 0 taken 93 times.
✓ Branch 1 taken 23608 times.
23701 else if(tempitem.family == itype_hammer)
9366 {
9367 93 tempitem.flags &= ~ITEM_FLAG3;
9368 93 }
9369
2/2
✓ Branch 0 taken 92 times.
✓ Branch 1 taken 23516 times.
23608 else if(tempitem.family == itype_cbyrna)
9370 {
9371 92 tempitem.flags |= ITEM_FLAG3;
9372
9373 92 tempitem.flags &= ~ITEM_FLAG6;
9374 92 }
9375
2/2
✓ Branch 0 taken 15705 times.
✓ Branch 1 taken 7811 times.
23516 else if(tempitem.family == itype_sword)
9376 {
9377
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7811 times.
7811 if(get_qr(qr_MELEEMAGICCOST))tempitem.flags |= ITEM_FLAG6;
9378 7811 else tempitem.flags &= ~ITEM_FLAG6;
9379 7811 }
9380 23808 }
9381
9382
2/2
✓ Branch 0 taken 8960 times.
✓ Branch 1 taken 23808 times.
32768 if( s_version < 43 )
9383 {
9384
2/2
✓ Branch 0 taken 23670 times.
✓ Branch 1 taken 138 times.
23808 if(tempitem.family == itype_whistle)
9385 {
9386
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 135 times.
138 if(get_qr(qr_WHIRLWINDMIRROR))tempitem.flags |= ITEM_FLAG3;
9387 135 else tempitem.flags &= ~ITEM_FLAG3;
9388 138 }
9389 23808 }
9390
9391
2/2
✓ Branch 0 taken 8960 times.
✓ Branch 1 taken 23808 times.
32768 if( s_version < 45 )
9392 {
9393
2/2
✓ Branch 0 taken 23715 times.
✓ Branch 1 taken 93 times.
23808 if(tempitem.family == itype_flippers)
9394 {
9395 93 tempitem.misc1 = 50; //Dive length, default 50 frames -V
9396 93 tempitem.misc2 = 30; //Dive cooldown, default 30 frames -V
9397 93 }
9398 23808 }
9399
9400
2/2
✓ Branch 0 taken 8960 times.
✓ Branch 1 taken 23808 times.
32768 if( s_version < 46 )
9401 {
9402
2/2
✓ Branch 0 taken 23716 times.
✓ Branch 1 taken 92 times.
23808 if(tempitem.family == itype_raft)
9403 {
9404 92 tempitem.misc1 = 1; //Rafting speed modifier; default 1. Negative slows, positive speeds.
9405 92 }
9406 23808 }
9407
2/2
✓ Branch 0 taken 8960 times.
✓ Branch 1 taken 23808 times.
32768 if ( s_version < 34 ) //! set the default counter for older quests.
9408 {
9409
2/2
✓ Branch 0 taken 75 times.
✓ Branch 1 taken 23733 times.
23808 if ( (tempitem.flags & ITEM_RUPEE_MAGIC) )
9410 {
9411 75 tempitem.cost_counter[0] = 1;
9412 75 }
9413 else
9414 {
9415
2/2
✓ Branch 0 taken 4608 times.
✓ Branch 1 taken 19125 times.
23733 if(get_qr(qr_ENABLEMAGIC))
9416 4608 tempitem.cost_counter[0] = 4;
9417 else
9418 {
9419 19125 tempitem.cost_amount[0] = 0;
9420 19125 tempitem.cost_counter[0] = -1;
9421 }
9422 }
9423 23808 }
9424
9425
2/2
✓ Branch 0 taken 8960 times.
✓ Branch 1 taken 23808 times.
32768 if ( s_version < 35 ) //new Lens of Truth flags
9426 {
9427
2/2
✓ Branch 0 taken 23716 times.
✓ Branch 1 taken 92 times.
23808 if ( tempitem.family == itype_lens )
9428 {
9429
2/2
✓ Branch 0 taken 89 times.
✓ Branch 1 taken 3 times.
92 if ( get_qr(qr_RAFTLENS) )
9430 {
9431 3 tempitem.flags |= ITEM_FLAG4;
9432 3 }
9433
2/2
✓ Branch 0 taken 40 times.
✓ Branch 1 taken 52 times.
92 if ( get_qr(qr_LENSHINTS) )
9434 {
9435 52 tempitem.flags |= ITEM_FLAG1;
9436 52 }
9437
2/2
✓ Branch 0 taken 88 times.
✓ Branch 1 taken 4 times.
92 if ( get_qr(qr_LENSSEESENEMIES) )
9438 {
9439 4 tempitem.flags |= ITEM_FLAG5;
9440 4 }
9441 92 }
9442 23808 }
9443
2/2
✓ Branch 0 taken 8960 times.
✓ Branch 1 taken 23808 times.
32768 if ( s_version < 44 ) //InitD Labels and Sprite Script Data
9444 {
9445
2/2
✓ Branch 0 taken 190464 times.
✓ Branch 1 taken 23808 times.
214272 for ( int32_t q = 0; q < 8; q++ )
9446 {
9447 190464 sprintf(tempitem.initD_label[q],"InitD[%d]",q);
9448 190464 sprintf(tempitem.weapon_initD_label[q],"InitD[%d]",q);
9449 190464 sprintf(tempitem.sprite_initD_label[q],"InitD[%d]",q);
9450 190464 tempitem.sprite_initiald[q] = 0;
9451 190464 }
9452
2/2
✓ Branch 0 taken 47616 times.
✓ Branch 1 taken 23808 times.
71424 for ( int32_t q = 0; q < 2; q++ ) tempitem.sprite_initiala[q] = 0;
9453 23808 tempitem.sprite_script = 0;
9454 23808 }
9455
2/2
✓ Branch 0 taken 8960 times.
✓ Branch 1 taken 23808 times.
32768 if ( s_version < 47 ) //InitD Labels and Sprite Script Data
9456 {
9457 23808 tempitem.pickupflag = 0;
9458 23808 }
9459
9460
2/2
✓ Branch 0 taken 8960 times.
✓ Branch 1 taken 23808 times.
32768 if( s_version < 51 )
9461 {
9462
2/2
✓ Branch 0 taken 23586 times.
✓ Branch 1 taken 222 times.
23808 if( tempitem.family == itype_candle )
9463 {
9464 222 tempitem.misc4 = 50; //Step speed
9465 222 }
9466 23808 }
9467
9468
2/2
✓ Branch 0 taken 8960 times.
✓ Branch 1 taken 23808 times.
32768 if( s_version < 52 )
9469 {
9470
2/2
✓ Branch 0 taken 23525 times.
✓ Branch 1 taken 283 times.
23808 if( tempitem.family == itype_shield )
9471 283 tempitem.flags |= ITEM_FLAG1; //'Block Front' flag
9472 23808 }
9473
2/2
✓ Branch 0 taken 8960 times.
✓ Branch 1 taken 23808 times.
32768 if(s_version < 53)
9474 {
9475
4/4
✓ Branch 0 taken 23335 times.
✓ Branch 1 taken 274 times.
✓ Branch 2 taken 107 times.
✓ Branch 3 taken 92 times.
23808 switch(tempitem.family)
9476 {
9477 case itype_arrow:
9478 274 tempitem.cost_counter[1] = crARROWS;
9479 274 tempitem.cost_amount[1] = 1;
9480 274 break;
9481 case itype_bomb:
9482 107 tempitem.cost_counter[1] = crBOMBS;
9483 107 tempitem.cost_amount[1] = 1;
9484 107 break;
9485 case itype_sbomb:
9486 92 tempitem.cost_counter[1] = crSBOMBS;
9487 92 tempitem.cost_amount[1] = 1;
9488 92 break;
9489 default:
9490 23335 tempitem.cost_counter[1] = crNONE;
9491 23335 tempitem.cost_amount[1] = 0;
9492 23335 }
9493 23808 tempitem.magiccosttimer[1] = 0;
9494 23808 }
9495
2/2
✓ Branch 0 taken 7680 times.
✓ Branch 1 taken 25088 times.
32768 if( s_version < 54 )
9496 {
9497
2/2
✓ Branch 0 taken 24989 times.
✓ Branch 1 taken 99 times.
25088 if( tempitem.family == itype_flippers )
9498 99 tempitem.misc3 = INT_BTN_A; //'Block Front' flag
9499 25088 }
9500
2/2
✓ Branch 0 taken 7680 times.
✓ Branch 1 taken 25088 times.
32768 if(s_version < 55)
9501 {
9502
3/3
✓ Branch 0 taken 194 times.
✓ Branch 1 taken 194 times.
✓ Branch 2 taken 24700 times.
25088 switch(tempitem.family)
9503 {
9504 case itype_spinscroll:
9505 case itype_quakescroll:
9506 194 tempitem.usesound2 = WAV_ZN1CHARGE;
9507 194 break;
9508 case itype_spinscroll2:
9509 case itype_quakescroll2:
9510 194 tempitem.usesound2 = WAV_ZN1CHARGE2;
9511 194 break;
9512 }
9513 25088 }
9514
2/2
✓ Branch 0 taken 7680 times.
✓ Branch 1 taken 25088 times.
32768 if(s_version < 56)
9515 {
9516
4/4
✓ Branch 0 taken 24645 times.
✓ Branch 1 taken 97 times.
✓ Branch 2 taken 234 times.
✓ Branch 3 taken 112 times.
25088 switch(tempitem.family)
9517 {
9518 case itype_divinefire:
9519
2/2
✓ Branch 0 taken 92 times.
✓ Branch 1 taken 5 times.
97 SETFLAG(tempitem.flags, ITEM_FLAG9, version < 0x255); //Strong Fire
9520
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 81 times.
97 SETFLAG(tempitem.flags, ITEM_FLAG10, version < 0x250); //Magic Fire
9521 97 tempitem.flags |= ITEM_FLAG11; //Divine Fire
9522 97 break;
9523 case itype_candle:
9524
2/2
✓ Branch 0 taken 114 times.
✓ Branch 1 taken 120 times.
234 SETFLAG(tempitem.flags, ITEM_FLAG9, tempitem.fam_type > 1); //Strong Fire
9525 234 tempitem.flags &= ~ITEM_FLAG10; //Magic Fire
9526 234 tempitem.flags &= ~ITEM_FLAG11; //Divine Fire
9527 234 break;
9528 case itype_book:
9529 112 tempitem.flags |= ITEM_FLAG9; //Strong Fire
9530 112 tempitem.flags |= ITEM_FLAG10; //Magic Fire
9531 112 tempitem.flags &= ~ITEM_FLAG11; //Divine Fire
9532 112 break;
9533 }
9534 25088 }
9535
9536
2/2
✓ Branch 0 taken 30624 times.
✓ Branch 1 taken 2144 times.
32768 if(tempitem.fam_type==0) // Always do this
9537 2144 tempitem.fam_type=1;
9538
9539 32768 memcpy(&itemsbuf[i], &tempitem, sizeof(itemdata));
9540 32768 }
9541
9542 128 return 0;
9543 128 }
9544
9545 static bool did_init_def_items = false;
9546 65728 void init_def_items()
9547 {
9548
2/2
✓ Branch 0 taken 65614 times.
✓ Branch 1 taken 114 times.
65728 if(did_init_def_items) return;
9549 114 did_init_def_items = true;
9550 114 default_items[3].cost_counter[1] = crBOMBS;
9551 114 default_items[13].cost_counter[1] = crARROWS;
9552 114 default_items[14].cost_counter[1] = crARROWS;
9553 114 default_items[48].cost_counter[1] = crSBOMBS;
9554 114 default_items[57].cost_counter[1] = crARROWS;
9555 65728 }
9556 65728 void reset_itembuf(itemdata *item, int32_t id)
9557 {
9558 65728 init_def_items();
9559
2/2
✓ Branch 0 taken 28024 times.
✓ Branch 1 taken 37704 times.
65728 if(id<iLast)
9560 {
9561 // Copy everything *EXCEPT* the tile, misc, cset, frames, speed, delay and ltm.
9562 37704 word tile = item->tile;
9563 37704 byte miscs = item->misc_flags, cset = item->csets, frames = item->frames, speed = item->speed, delay = item->delay;
9564 37704 int32_t ltm = item->ltm;
9565
9566 37704 memcpy(item,&default_items[id],sizeof(itemdata));
9567 37704 item->tile = tile;
9568 37704 item->misc_flags = miscs;
9569 37704 item->csets = cset;
9570 37704 item->frames = frames;
9571 37704 item->speed = speed;
9572 37704 item->delay = delay;
9573 37704 item->ltm = ltm;
9574 37704 }
9575 65728 }
9576
9577 33280 void reset_itemname(int32_t id)
9578 {
9579 33280 sprintf(item_string[id],"zz%03d",id);
9580
9581
2/2
✓ Branch 0 taken 14690 times.
✓ Branch 1 taken 18590 times.
33280 if(id < iLast)
9582 18590 strcpy(item_string[id],old_item_string[id]);
9583 33280 }
9584
9585 128 int32_t readweapons(PACKFILE *f, zquestheader *Header)
9586 {
9587
2/2
✓ Branch 0 taken 124 times.
✓ Branch 1 taken 4 times.
128 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_weapons);
9588
9589 128 word weapons_to_read=MAXWPNS;
9590 int32_t dummy;
9591 byte padding;
9592 wpndata tempweapon;
9593 128 word s_version=0, s_cversion=0;
9594
9595
9596
1/2
✓ Branch 0 taken 128 times.
✗ Branch 1 not taken.
128 if(Header->zelda_version < 0x186)
9597 {
9598 weapons_to_read=64;
9599 }
9600
9601
1/2
✓ Branch 0 taken 128 times.
✗ Branch 1 not taken.
128 if(Header->zelda_version < 0x185)
9602 {
9603 weapons_to_read=32;
9604 }
9605
9606
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 124 times.
128 if(Header->zelda_version > 0x192)
9607 {
9608 124 weapons_to_read=0;
9609
9610 //section version info
9611
1/2
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
124 if(!p_igetw(&s_version,f))
9612 {
9613 return qe_invalid;
9614 }
9615
9616 124 FFCore.quest_format[vWeaponSprites] = s_version;
9617
9618 //al_trace("Weapons version %d\n", s_version);
9619
1/2
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
124 if(!p_igetw(&s_cversion,f))
9620 {
9621 return qe_invalid;
9622 }
9623
9624 //section size
9625
1/2
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
124 if(!p_igetl(&dummy,f))
9626 {
9627 return qe_invalid;
9628 }
9629
9630 //finally... section data
9631
1/2
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
124 if(!p_igetw(&weapons_to_read,f))
9632 {
9633 return qe_invalid;
9634 }
9635
9636
2/4
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 124 times.
124 if (!(weapons_to_read >= 0 && weapons_to_read <= MAXWPNS))
9637 {
9638 return qe_invalid;
9639 }
9640 124 }
9641
9642
2/2
✓ Branch 0 taken 112 times.
✓ Branch 1 taken 16 times.
128 if(s_version>2)
9643 {
9644
2/2
✓ Branch 0 taken 28672 times.
✓ Branch 1 taken 112 times.
28784 for(int32_t i=0; i<weapons_to_read; i++)
9645 {
9646 char tempname[64];
9647
9648
1/2
✓ Branch 0 taken 28672 times.
✗ Branch 1 not taken.
28672 if(!pfread(tempname, 64, f))
9649 {
9650 return qe_invalid;
9651 }
9652
9653 28672 weapon_string[i][0] = '\0';
9654 28672 strncat(weapon_string[i], tempname, 64 - 1);
9655 28672 }
9656
9657
1/2
✓ Branch 0 taken 112 times.
✗ Branch 1 not taken.
112 if(s_version<4)
9658 {
9659 strcpy(weapon_string[iwHover],old_weapon_string[iwHover]);
9660 strcpy(weapon_string[wFIREMAGIC],old_weapon_string[wFIREMAGIC]);
9661 }
9662
9663
1/2
✓ Branch 0 taken 112 times.
✗ Branch 1 not taken.
112 if(s_version<5)
9664 {
9665 strcpy(weapon_string[iwQuarterHearts],old_weapon_string[iwQuarterHearts]);
9666 }
9667
9668 /*
9669 if (s_version<6)
9670 {
9671 strcpy(weapon_string[iwSideRaft],old_weapon_string[iwSideRaft]);
9672 strcpy(weapon_string[iwSideLadder],old_weapon_string[iwSideLadder]);
9673 }
9674 */
9675 112 }
9676
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 else if (!should_skip)
9677 {
9678
2/2
✓ Branch 0 taken 4096 times.
✓ Branch 1 taken 16 times.
4112 for(int32_t i=0; i<MAXWPNS; i++)
9679 4096 reset_weaponname(i);
9680 16 }
9681
9682
2/2
✓ Branch 0 taken 30512 times.
✓ Branch 1 taken 128 times.
30640 for(int32_t i=0; i<weapons_to_read; i++)
9683 {
9684 30512 word oldtile = 0;
9685
2/2
✓ Branch 0 taken 8448 times.
✓ Branch 1 taken 22064 times.
30512 if (s_version < 8)
9686 {
9687
1/2
✓ Branch 0 taken 22064 times.
✗ Branch 1 not taken.
22064 if (!p_igetw(&oldtile, f))
9688 return qe_invalid;
9689 22064 }
9690
9691
1/2
✓ Branch 0 taken 30512 times.
✗ Branch 1 not taken.
30512 if(!p_getc(&tempweapon.misc,f))
9692 {
9693 return qe_invalid;
9694 }
9695
9696
1/2
✓ Branch 0 taken 30512 times.
✗ Branch 1 not taken.
30512 if(!p_getc(&tempweapon.csets,f))
9697 {
9698 return qe_invalid;
9699 }
9700
9701
1/2
✓ Branch 0 taken 30512 times.
✗ Branch 1 not taken.
30512 if(!p_getc(&tempweapon.frames,f))
9702 {
9703 return qe_invalid;
9704 }
9705
9706
1/2
✓ Branch 0 taken 30512 times.
✗ Branch 1 not taken.
30512 if(!p_getc(&tempweapon.speed,f))
9707 {
9708 return qe_invalid;
9709 }
9710
9711
1/2
✓ Branch 0 taken 30512 times.
✗ Branch 1 not taken.
30512 if(!p_getc(&tempweapon.type,f))
9712 {
9713 return qe_invalid;
9714 }
9715
9716
2/2
✓ Branch 0 taken 21552 times.
✓ Branch 1 taken 8960 times.
30512 if ( s_version >= 7 )
9717 {
9718
1/2
✓ Branch 0 taken 8960 times.
✗ Branch 1 not taken.
8960 if(!p_igetw(&tempweapon.script,f))
9719 {
9720 return qe_invalid;
9721 }
9722
1/2
✓ Branch 0 taken 8960 times.
✗ Branch 1 not taken.
8960 if(!p_igetl(&tempweapon.tile,f))
9723 {
9724 return qe_invalid;
9725 }
9726 8960 }
9727
2/2
✓ Branch 0 taken 8960 times.
✓ Branch 1 taken 21552 times.
30512 if ( s_version < 7 )
9728 {
9729 21552 tempweapon.tile = oldtile;
9730 21552 }
9731
9732
2/2
✓ Branch 0 taken 29488 times.
✓ Branch 1 taken 1024 times.
30512 if(Header->zelda_version < 0x193)
9733 {
9734
1/2
✓ Branch 0 taken 1024 times.
✗ Branch 1 not taken.
1024 if(!p_getc(&padding,f))
9735 {
9736 return qe_invalid;
9737 }
9738 1024 }
9739
9740
2/2
✓ Branch 0 taken 28672 times.
✓ Branch 1 taken 1840 times.
30512 if(s_version < 6)
9741 {
9742
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 1836 times.
1840 if(i==ewFIRETRAIL)
9743 {
9744 4 tempweapon.misc |= WF_BEHIND;
9745 4 }
9746 else
9747 1836 tempweapon.misc &= ~WF_BEHIND;
9748 1840 }
9749
9750
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 30512 times.
30512 if (!should_skip)
9751 30512 memcpy(&wpnsbuf[i], &tempweapon, sizeof(tempweapon));
9752 30512 }
9753
9754
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 128 times.
128 if (should_skip)
9755 return 0;
9756
9757
2/2
✓ Branch 0 taken 112 times.
✓ Branch 1 taken 16 times.
128 if(s_version<2)
9758 {
9759 16 wpnsbuf[wSBOOM]=wpnsbuf[wBOOM];
9760 16 }
9761
9762
2/2
✓ Branch 0 taken 112 times.
✓ Branch 1 taken 16 times.
128 if(s_version<5)
9763 {
9764 16 wpnsbuf[iwQuarterHearts].tile=1;
9765 16 wpnsbuf[iwQuarterHearts].csets=1;
9766 16 }
9767
9768
1/2
✓ Branch 0 taken 128 times.
✗ Branch 1 not taken.
128 if(Header->zelda_version < 0x176)
9769 {
9770 wpnsbuf[iwSpawn] = *((wpndata*)(itemsbuf + iMisc1));
9771 wpnsbuf[iwDeath] = *((wpndata*)(itemsbuf + iMisc2));
9772 memset(&itemsbuf[iMisc1],0,sizeof(itemdata));
9773 memset(&itemsbuf[iMisc2],0,sizeof(itemdata));
9774 }
9775
9776
2/4
✓ Branch 0 taken 124 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
128 if((Header->zelda_version < 0x192)||
9777
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 124 times.
124 ((Header->zelda_version == 0x192)&&(Header->build<129)))
9778 {
9779 4 wpnsbuf[wHSCHAIN_V] = wpnsbuf[wHSCHAIN_H];
9780 4 }
9781
9782
2/2
✓ Branch 0 taken 124 times.
✓ Branch 1 taken 4 times.
128 if((Header->zelda_version < 0x210))
9783 {
9784 4 wpnsbuf[wLSHEAD] = wpnsbuf[wHSHEAD];
9785 4 wpnsbuf[wLSCHAIN_H] = wpnsbuf[wHSCHAIN_H];
9786 4 wpnsbuf[wLSHANDLE] = wpnsbuf[wHSHANDLE];
9787 4 wpnsbuf[wLSCHAIN_V] = wpnsbuf[wHSCHAIN_V];
9788 4 }
9789
9790 128 return 0;
9791 128 }
9792
9793 128 void init_guys(int32_t guyversion)
9794 {
9795
2/2
✓ Branch 0 taken 65536 times.
✓ Branch 1 taken 128 times.
65664 for(int32_t i=0; i<MAXGUYS; i++)
9796 {
9797 65536 guysbuf[i] = default_guys[0];
9798 65536 }
9799
9800
2/2
✓ Branch 0 taken 22656 times.
✓ Branch 1 taken 128 times.
22784 for(int32_t i=0; i<OLDMAXGUYS; i++)
9801 {
9802 22656 guysbuf[i] = default_guys[i];
9803
2/2
✓ Branch 0 taken 22400 times.
✓ Branch 1 taken 256 times.
22656 guysbuf[i].spr_shadow = (guysbuf[i].family==eeROCK && guysbuf[i].misc10==1) ? iwLargeShadow : iwShadow;
9804 22656 guysbuf[i].spr_death = iwDeath;
9805 22656 guysbuf[i].spr_spawn = iwSpawn;
9806 // Patra fix: 2.10 BSPatras used spDIG. 2.50 Patras use CSet 7.
9807
4/4
✓ Branch 0 taken 2832 times.
✓ Branch 1 taken 19824 times.
✓ Branch 2 taken 2816 times.
✓ Branch 3 taken 16 times.
22656 if(guyversion<=3 && i==ePATRABS)
9808 {
9809 16 guysbuf[i].bosspal=spDIG;
9810 16 guysbuf[i].cset=14;
9811 16 guysbuf[i].misc9=14;
9812 16 }
9813
9814
2/2
✓ Branch 0 taken 19824 times.
✓ Branch 1 taken 2832 times.
22656 if(guyversion<=3)
9815 {
9816 // Rope/Ghini Flash rules
9817
2/2
✓ Branch 0 taken 708 times.
✓ Branch 1 taken 2124 times.
2832 if(get_bit(deprecated_rules, qr_NOROPE2FLASH_DEP))
9818 {
9819
2/2
✓ Branch 0 taken 2112 times.
✓ Branch 1 taken 12 times.
2124 if(i==eROPE2)
9820 {
9821 12 guysbuf[i].flags2 &= ~guy_flashing;
9822 12 }
9823 2124 }
9824
9825
2/2
✓ Branch 0 taken 2301 times.
✓ Branch 1 taken 531 times.
2832 if(get_bit(deprecated_rules, qr_NOBUBBLEFLASH_DEP))
9826 {
9827
12/12
✓ Branch 0 taken 528 times.
✓ Branch 1 taken 3 times.
✓ Branch 2 taken 525 times.
✓ Branch 3 taken 3 times.
✓ Branch 4 taken 522 times.
✓ Branch 5 taken 3 times.
✓ Branch 6 taken 519 times.
✓ Branch 7 taken 3 times.
✓ Branch 8 taken 516 times.
✓ Branch 9 taken 3 times.
✓ Branch 10 taken 3 times.
✓ Branch 11 taken 513 times.
531 if(i==eBUBBLEST || i==eBUBBLESP || i==eBUBBLESR || i==eBUBBLEIT || i==eBUBBLEIP || i==eBUBBLEIR)
9828 {
9829 18 guysbuf[i].flags2 &= ~guy_flashing;
9830 18 }
9831 531 }
9832
9833
2/2
✓ Branch 0 taken 2816 times.
✓ Branch 1 taken 16 times.
2832 if(i==eGHINI2)
9834 {
9835
2/2
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 3 times.
16 if(get_bit(deprecated_rules, qr_GHINI2BLINK_DEP))
9836 {
9837 3 guysbuf[i].flags2 |= guy_blinking;
9838 3 }
9839
9840
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(get_bit(deprecated_rules, qr_PHANTOMGHINI2_DEP))
9841 {
9842 guysbuf[i].flags2 |= guy_transparent;
9843 }
9844 16 }
9845 2832 }
9846
9847 // Darknut fix
9848
10/10
✓ Branch 0 taken 22528 times.
✓ Branch 1 taken 128 times.
✓ Branch 2 taken 22400 times.
✓ Branch 3 taken 128 times.
✓ Branch 4 taken 22272 times.
✓ Branch 5 taken 128 times.
✓ Branch 6 taken 22144 times.
✓ Branch 7 taken 128 times.
✓ Branch 8 taken 128 times.
✓ Branch 9 taken 22016 times.
22656 if(i==eDKNUT1 || i==eDKNUT2 || i==eDKNUT3 || i==eDKNUT4 || i==eDKNUT5)
9849 {
9850
2/2
✓ Branch 0 taken 430 times.
✓ Branch 1 taken 210 times.
640 if(get_qr(qr_NEWENEMYTILES))
9851 {
9852 430 guysbuf[i].s_tile=guysbuf[i].e_tile+120;
9853 430 guysbuf[i].s_width=guysbuf[i].e_width;
9854 430 guysbuf[i].s_height=guysbuf[i].e_height;
9855 430 }
9856 210 else guysbuf[i].s_tile=860;
9857
9858
2/2
✓ Branch 0 taken 560 times.
✓ Branch 1 taken 80 times.
640 if(get_bit(deprecated_rules,qr_BRKBLSHLDS_DEP))
9859 {
9860 80 guysbuf[i].flags |= guy_bkshield;
9861 80 }
9862 640 }
9863
9864
4/4
✓ Branch 0 taken 22528 times.
✓ Branch 1 taken 128 times.
✓ Branch 2 taken 22648 times.
✓ Branch 3 taken 8 times.
22656 if((i==eGELTRIB || i==eFGELTRIB) && get_bit(deprecated_rules,qr_OLDTRIBBLES_DEP))
9865 {
9866 8 guysbuf[i].misc3 = (i==eFGELTRIB ? eFZOL : eZOL);
9867 8 }
9868 22656 }
9869 128 }
9870
9871 4096 void reset_weaponname(int32_t i)
9872 {
9873
2/2
✓ Branch 0 taken 1408 times.
✓ Branch 1 taken 2688 times.
4096 if(i<wLast)
9874 {
9875 1408 strcpy(weapon_string[i],old_weapon_string[i]);
9876 1408 }
9877 else
9878 2688 sprintf(weapon_string[i],"zz%03d",i);
9879 4096 }
9880
9881 128 void init_item_drop_sets()
9882 {
9883
2/2
✓ Branch 0 taken 32768 times.
✓ Branch 1 taken 128 times.
32896 for(int32_t i=0; i<MAXITEMDROPSETS; i++)
9884 {
9885 // item_drop_sets[i] = default_item_drop_sets[0];
9886 32768 memset(&item_drop_sets[i], 0, sizeof(item_drop_object));
9887 32768 }
9888
9889
2/2
✓ Branch 0 taken 1664 times.
✓ Branch 1 taken 128 times.
1792 for(int32_t i=0; i<isMAX; i++)
9890 {
9891 1664 item_drop_sets[i] = default_item_drop_sets[i];
9892
9893 // Deprecated: qr_NOCLOCKS and qr_ALLOW10RUPEEDROPS
9894
2/2
✓ Branch 0 taken 16640 times.
✓ Branch 1 taken 1664 times.
18304 for(int32_t j=0; j<10; ++j)
9895 {
9896 16640 int32_t it = item_drop_sets[i].item[j];
9897
9898
3/4
✓ Branch 0 taken 11684 times.
✓ Branch 1 taken 4956 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 750 times.
16640 if((itemsbuf[it].family == itype_rupee && ((itemsbuf[it].amount)&0xFFF) == 10)
9899
2/2
✓ Branch 0 taken 750 times.
✓ Branch 1 taken 10934 times.
11684 && !get_bit(deprecated_rules, qr_ALLOW10RUPEEDROPS_DEP))
9900 {
9901 750 item_drop_sets[i].chance[j+1]=0;
9902 750 }
9903
3/4
✓ Branch 0 taken 512 times.
✓ Branch 1 taken 15378 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 512 times.
15890 else if(itemsbuf[it].family == itype_clock && get_bit(deprecated_rules, qr_NOCLOCKS_DEP))
9904 {
9905 item_drop_sets[i].chance[j+1]=0;
9906 }
9907
9908 // From Sept 2007 to Dec 2008, non-gameplay items were prohibited.
9909
2/2
✓ Branch 0 taken 16632 times.
✓ Branch 1 taken 8 times.
16640 if(itemsbuf[it].family == itype_misc)
9910 {
9911 // If a non-gameplay item was selected, then item drop was aborted.
9912 // Reflect this by increasing the 'Nothing' chance accordingly.
9913 8 item_drop_sets[i].chance[0]+=item_drop_sets[i].chance[j+1];
9914 8 item_drop_sets[i].chance[j+1]=0;
9915 8 }
9916 16640 }
9917 1664 }
9918 128 }
9919
9920 128 void init_favorites()
9921 {
9922
2/2
✓ Branch 0 taken 161280 times.
✓ Branch 1 taken 128 times.
161408 for(int32_t i=0; i<MAXFAVORITECOMBOS; i++)
9923 {
9924 161280 favorite_combos[i]=-1;
9925 161280 }
9926 128 }
9927
9928 const char *ctype_name[cMAX]=
9929 {
9930 "cNONE", "cSTAIR", "cCAVE", "cWATER", "cARMOS", "cGRAVE", "cDOCK",
9931 "cUNDEF", "cPUSH_WAIT", "cPUSH_HEAVY", "cPUSH_HW", "cL_STATUE", "cR_STATUE",
9932 "cWALKSLOW", "cCVUP", "cCVDOWN", "cCVLEFT", "cCVRIGHT", "cSWIMWARP", "cDIVEWARP",
9933 "cLADDERHOOKSHOT", "cTRIGNOFLAG", "cTRIGFLAG", "cZELDA", "cSLASH", "cSLASHITEM",
9934 "cPUSH_HEAVY2", "cPUSH_HW2", "cPOUND", "cHSGRAB", "cHSBRIDGE", "cDAMAGE1",
9935 "cDAMAGE2", "cDAMAGE3", "cDAMAGE4", "cC_STATUE", "cTRAP_H", "cTRAP_V", "cTRAP_4",
9936 "cTRAP_LR", "cTRAP_UD", "cPIT", "cHOOKSHOTONLY", "cOVERHEAD", "cNOFLYZONE", "cMIRROR",
9937 "cMIRRORSLASH", "cMIRRORBACKSLASH", "cMAGICPRISM", "cMAGICPRISM4",
9938 "cMAGICSPONGE", "cCAVE2", "cEYEBALL_A", "cEYEBALL_B", "cNOJUMPZONE", "cBUSH",
9939 "cFLOWERS", "cTALLGRASS", "cSHALLOWWATER", "cLOCKBLOCK", "cLOCKBLOCK2",
9940 "cBOSSLOCKBLOCK", "cBOSSLOCKBLOCK2", "cLADDERONLY", "cBSGRAVE",
9941 "cCHEST", "cCHEST2", "cLOCKEDCHEST", "cLOCKEDCHEST2", "cBOSSCHEST", "cBOSSCHEST2",
9942 "cRESET", "cSAVE", "cSAVE2", "cCAVEB", "cCAVEC", "cCAVED",
9943 "cSTAIRB", "cSTAIRC", "cSTAIRD", "cPITB", "cPITC", "cPITD",
9944 "cCAVE2B", "cCAVE2C", "cCAVE2D", "cSWIMWARPB", "cSWIMWARPC", "cSWIMWARPD",
9945 "cDIVEWARPB", "cDIVEWARPC", "cDIVEWARPD", "cSTAIRR", "cPITR",
9946 "cAWARPA", "cAWARPB", "cAWARPC", "cAWARPD", "cAWARPR",
9947 "cSWARPA", "cSWARPB", "cSWARPC", "cSWARPD", "cSWARPR", "cSTRIGNOFLAG", "cSTRIGFLAG",
9948 "cSTEP", "cSTEPSAME", "cSTEPALL", "cSTEPCOPY", "cNOENEMY", "cBLOCKARROW1", "cBLOCKARROW2",
9949 "cBLOCKARROW3", "cBLOCKBRANG1", "cBLOCKBRANG2", "cBLOCKBRANG3", "cBLOCKSBEAM", "cBLOCKALL",
9950 "cBLOCKFIREBALL", "cDAMAGE5", "cDAMAGE6", "cDAMAGE7", "cCHANGE", "cSPINTILE1", "cSPINTILE2",
9951 "cSCREENFREEZE", "cSCREENFREEZEFF", "cNOGROUNDENEMY", "cSLASHNEXT", "cSLASHNEXTITEM", "cBUSHNEXT"
9952 "cSLASHTOUCHY", "cSLASHITEMTOUCHY", "cBUSHTOUCHY", "cFLOWERSTOUCHY", "cTALLGRASSTOUCHY",
9953 "cSLASHNEXTTOUCHY", "cSLASHNEXTITEMTOUCHY", "cBUSHNEXTTOUCHY", "cEYEBALL_4", "cTALLGRASSNEXT",
9954 "cSCRIPT1", "cSCRIPT2", "cSCRIPT3", "cSCRIPT4", "cSCRIPT5",
9955 "cSCRIPT6", "cSCRIPT7", "cSCRIPT8", "cSCRIPT9", "cSCRIPT10",
9956 "cSCRIPT11", "cSCRIPT12", "cSCRIPT13", "cSCRIPT14", "cSCRIPT15",
9957 "cSCRIPT16", "cSCRIPT17", "cSCRIPT18", "cSCRIPT19", "cSCRIPT20"
9958
9959 };
9960
9961 223 int32_t init_combo_classes()
9962 {
9963
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 223 times.
223 zinfo* zi = (load_tmp_zi ? load_tmp_zi : &ZI);
9964
2/2
✓ Branch 0 taken 40586 times.
✓ Branch 1 taken 223 times.
40809 for(int32_t i=0; i<cMAX; i++)
9965 {
9966 40586 combo_class_buf[i] = default_combo_classes[i];
9967
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 40586 times.
40586 if ( char const* nm = zi->getComboTypeName(i) )
9968 {
9969 40586 size_t len = strlen(nm);
9970
2/2
✓ Branch 0 taken 2597504 times.
✓ Branch 1 taken 40586 times.
2638090 for ( size_t q = 0; q < 64; q++ )
9971 {
9972
2/2
✓ Branch 0 taken 595856 times.
✓ Branch 1 taken 2001648 times.
2597504 combo_class_buf[i].name[q] = (q<len ? nm[q] : 0);
9973 2597504 }
9974 40586 }
9975 40586 }
9976
9977 223 return 0;
9978 }
9979
9980 97 int32_t readherosprites2(PACKFILE *f, int32_t v_herosprites, int32_t cv_herosprites)
9981 {
9982
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 89 times.
97 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_herosprites);
9983
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 97 times.
97 if (should_skip) return 0;
9984
9985
1/2
✓ Branch 0 taken 97 times.
✗ Branch 1 not taken.
97 assert(v_herosprites < 6);
9986 //these are here to bypass compiler warnings about unused arguments
9987 97 cv_herosprites=cv_herosprites;
9988
9989 97 zinit.hero_swim_speed=67; //default
9990 97 setupherotiles(zinit.heroAnimationStyle);
9991 97 setupherodefenses();
9992 97 setupherooffsets();
9993
9994
2/2
✓ Branch 0 taken 20 times.
✓ Branch 1 taken 77 times.
97 if(v_herosprites>=0)
9995 {
9996 word tile, tile2;
9997 byte flip, extend, dummy_byte;
9998
9999
2/2
✓ Branch 0 taken 308 times.
✓ Branch 1 taken 77 times.
385 for(int32_t i=0; i<4; i++)
10000 {
10001
1/2
✓ Branch 0 taken 308 times.
✗ Branch 1 not taken.
308 if(!p_igetw(&tile,f))
10002 {
10003 return qe_invalid;
10004 }
10005
10006
1/2
✓ Branch 0 taken 308 times.
✗ Branch 1 not taken.
308 if(!p_getc(&flip,f))
10007 {
10008 return qe_invalid;
10009 }
10010
10011
1/2
✓ Branch 0 taken 308 times.
✗ Branch 1 not taken.
308 if(!p_getc(&extend,f))
10012 {
10013 return qe_invalid;
10014 }
10015
10016 308 walkspr[i][spr_tile]=(int32_t)tile;
10017 308 walkspr[i][spr_flip]=(int32_t)flip;
10018 308 walkspr[i][spr_extend]=(int32_t)extend;
10019 308 }
10020
10021
2/2
✓ Branch 0 taken 308 times.
✓ Branch 1 taken 77 times.
385 for(int32_t i=0; i<4; i++)
10022 {
10023
1/2
✓ Branch 0 taken 308 times.
✗ Branch 1 not taken.
308 if(!p_igetw(&tile,f))
10024 {
10025 return qe_invalid;
10026 }
10027
10028
1/2
✓ Branch 0 taken 308 times.
✗ Branch 1 not taken.
308 if(!p_getc(&flip,f))
10029 {
10030 return qe_invalid;
10031 }
10032
10033
1/2
✓ Branch 0 taken 308 times.
✗ Branch 1 not taken.
308 if(!p_getc(&extend,f))
10034 {
10035 return qe_invalid;
10036 }
10037
10038 308 stabspr[i][spr_tile]=(int32_t)tile;
10039 308 stabspr[i][spr_flip]=(int32_t)flip;
10040 308 stabspr[i][spr_extend]=(int32_t)extend;
10041 308 }
10042
10043
2/2
✓ Branch 0 taken 308 times.
✓ Branch 1 taken 77 times.
385 for(int32_t i=0; i<4; i++)
10044 {
10045
1/2
✓ Branch 0 taken 308 times.
✗ Branch 1 not taken.
308 if(!p_igetw(&tile,f))
10046 {
10047 return qe_invalid;
10048 }
10049
10050
1/2
✓ Branch 0 taken 308 times.
✗ Branch 1 not taken.
308 if(!p_getc(&flip,f))
10051 {
10052 return qe_invalid;
10053 }
10054
10055
1/2
✓ Branch 0 taken 308 times.
✗ Branch 1 not taken.
308 if(!p_getc(&extend,f))
10056 {
10057 return qe_invalid;
10058 }
10059
10060 308 slashspr[i][spr_tile]=(int32_t)tile;
10061 308 slashspr[i][spr_flip]=(int32_t)flip;
10062 308 slashspr[i][spr_extend]=(int32_t)extend;
10063 308 }
10064
10065
2/2
✓ Branch 0 taken 308 times.
✓ Branch 1 taken 77 times.
385 for(int32_t i=0; i<4; i++)
10066 {
10067
1/2
✓ Branch 0 taken 308 times.
✗ Branch 1 not taken.
308 if(!p_igetw(&tile,f))
10068 {
10069 return qe_invalid;
10070 }
10071
10072
1/2
✓ Branch 0 taken 308 times.
✗ Branch 1 not taken.
308 if(!p_getc(&flip,f))
10073 {
10074 return qe_invalid;
10075 }
10076
10077
1/2
✓ Branch 0 taken 308 times.
✗ Branch 1 not taken.
308 if(!p_getc(&extend,f))
10078 {
10079 return qe_invalid;
10080 }
10081
10082 308 floatspr[i][spr_tile]=(int32_t)tile;
10083 308 floatspr[i][spr_flip]=(int32_t)flip;
10084 308 floatspr[i][spr_extend]=(int32_t)extend;
10085 308 }
10086
10087
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 77 times.
77 if(v_herosprites>1)
10088 {
10089
2/2
✓ Branch 0 taken 308 times.
✓ Branch 1 taken 77 times.
385 for(int32_t i=0; i<4; i++)
10090 {
10091
1/2
✓ Branch 0 taken 308 times.
✗ Branch 1 not taken.
308 if(!p_igetw(&tile,f))
10092 {
10093 return qe_invalid;
10094 }
10095
10096
1/2
✓ Branch 0 taken 308 times.
✗ Branch 1 not taken.
308 if(!p_getc(&flip,f))
10097 {
10098 return qe_invalid;
10099 }
10100
10101
1/2
✓ Branch 0 taken 308 times.
✗ Branch 1 not taken.
308 if(!p_getc(&extend,f))
10102 {
10103 return qe_invalid;
10104 }
10105
10106 308 swimspr[i][spr_tile]=(int32_t)tile;
10107 308 swimspr[i][spr_flip]=(int32_t)flip;
10108 308 swimspr[i][spr_extend]=(int32_t)extend;
10109 308 }
10110 77 }
10111
10112
2/2
✓ Branch 0 taken 308 times.
✓ Branch 1 taken 77 times.
385 for(int32_t i=0; i<4; i++)
10113 {
10114
1/2
✓ Branch 0 taken 308 times.
✗ Branch 1 not taken.
308 if(!p_igetw(&tile,f))
10115 {
10116 return qe_invalid;
10117 }
10118
10119
1/2
✓ Branch 0 taken 308 times.
✗ Branch 1 not taken.
308 if(!p_getc(&flip,f))
10120 {
10121 return qe_invalid;
10122 }
10123
10124
1/2
✓ Branch 0 taken 308 times.
✗ Branch 1 not taken.
308 if(!p_getc(&extend,f))
10125 {
10126 return qe_invalid;
10127 }
10128
10129 308 divespr[i][spr_tile]=(int32_t)tile;
10130 308 divespr[i][spr_flip]=(int32_t)flip;
10131 308 divespr[i][spr_extend]=(int32_t)extend;
10132 308 }
10133
10134
2/2
✓ Branch 0 taken 308 times.
✓ Branch 1 taken 77 times.
385 for(int32_t i=0; i<4; i++)
10135 {
10136
1/2
✓ Branch 0 taken 308 times.
✗ Branch 1 not taken.
308 if(!p_igetw(&tile,f))
10137 {
10138 return qe_invalid;
10139 }
10140
10141
1/2
✓ Branch 0 taken 308 times.
✗ Branch 1 not taken.
308 if(!p_getc(&flip,f))
10142 {
10143 return qe_invalid;
10144 }
10145
10146
1/2
✓ Branch 0 taken 308 times.
✗ Branch 1 not taken.
308 if(!p_getc(&extend,f))
10147 {
10148 return qe_invalid;
10149 }
10150
10151 308 poundspr[i][spr_tile]=(int32_t)tile;
10152 308 poundspr[i][spr_flip]=(int32_t)flip;
10153 308 poundspr[i][spr_extend]=(int32_t)extend;
10154 308 }
10155
10156
1/2
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
77 if(!p_igetw(&tile,f))
10157 {
10158 return qe_invalid;
10159 }
10160
10161 77 flip=0;
10162
10163
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 77 times.
77 if(v_herosprites>0)
10164 {
10165
1/2
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
77 if(!p_getc(&flip,f))
10166 {
10167 return qe_invalid;
10168 }
10169 77 }
10170
10171
1/2
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
77 if(!p_getc(&extend,f))
10172 {
10173 return qe_invalid;
10174 }
10175
10176 77 castingspr[spr_tile]=(int32_t)tile;
10177 77 castingspr[spr_flip]=(int32_t)flip;
10178 77 castingspr[spr_extend]=(int32_t)extend;
10179
10180
1/2
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
77 if(v_herosprites>0)
10181 {
10182 77 int32_t num_holdsprs = (v_herosprites > 6 ? 3 : 2);
10183
2/2
✓ Branch 0 taken 154 times.
✓ Branch 1 taken 77 times.
231 for(int32_t i=0; i<2; i++)
10184 {
10185
2/2
✓ Branch 0 taken 308 times.
✓ Branch 1 taken 154 times.
462 for(int32_t j=0; j<num_holdsprs; j++)
10186 {
10187
1/2
✓ Branch 0 taken 308 times.
✗ Branch 1 not taken.
308 if(!p_igetw(&tile,f))
10188 {
10189 return qe_invalid;
10190 }
10191
10192
1/2
✓ Branch 0 taken 308 times.
✗ Branch 1 not taken.
308 if(!p_getc(&flip,f))
10193 {
10194 return qe_invalid;
10195 }
10196
10197
1/2
✓ Branch 0 taken 308 times.
✗ Branch 1 not taken.
308 if(!p_getc(&extend,f))
10198 {
10199 return qe_invalid;
10200 }
10201
10202 308 holdspr[i][j][spr_tile]=(int32_t)tile;
10203 308 holdspr[i][j][spr_flip]=(int32_t)flip;
10204 308 holdspr[i][j][spr_extend]=(int32_t)extend;
10205 308 }
10206 154 }
10207 77 }
10208 else
10209 {
10210 for(int32_t i=0; i<2; i++)
10211 {
10212 if(!p_igetw(&tile,f))
10213 {
10214 return qe_invalid;
10215 }
10216
10217 if(!p_igetw(&tile2,f))
10218 {
10219 return qe_invalid;
10220 }
10221
10222 if(!p_getc(&extend,f))
10223 {
10224 return qe_invalid;
10225 }
10226
10227 holdspr[i][spr_hold1][spr_tile]=(int32_t)tile;
10228 holdspr[i][spr_hold1][spr_flip]=(int32_t)flip;
10229 holdspr[i][spr_hold1][spr_extend]=(int32_t)extend;
10230 holdspr[i][spr_hold2][spr_tile]=(int32_t)tile2;
10231 holdspr[i][spr_hold2][spr_flip]=(int32_t)flip;
10232 holdspr[i][spr_hold2][spr_extend]=(int32_t)extend;
10233 }
10234 }
10235
10236
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 77 times.
77 if(v_herosprites>2)
10237 {
10238
2/2
✓ Branch 0 taken 308 times.
✓ Branch 1 taken 77 times.
385 for(int32_t i=0; i<4; i++)
10239 {
10240
1/2
✓ Branch 0 taken 308 times.
✗ Branch 1 not taken.
308 if(!p_igetw(&tile,f))
10241 {
10242 return qe_invalid;
10243 }
10244
10245
1/2
✓ Branch 0 taken 308 times.
✗ Branch 1 not taken.
308 if(!p_getc(&flip,f))
10246 {
10247 return qe_invalid;
10248 }
10249
10250
1/2
✓ Branch 0 taken 308 times.
✗ Branch 1 not taken.
308 if(!p_getc(&extend,f))
10251 {
10252 return qe_invalid;
10253 }
10254
10255 308 jumpspr[i][spr_tile]=(int32_t)tile;
10256 308 jumpspr[i][spr_flip]=(int32_t)flip;
10257 308 jumpspr[i][spr_extend]=(int32_t)extend;
10258 308 }
10259 77 }
10260
10261
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 77 times.
77 if(v_herosprites>3)
10262 {
10263
2/2
✓ Branch 0 taken 308 times.
✓ Branch 1 taken 77 times.
385 for(int32_t i=0; i<4; i++)
10264 {
10265
1/2
✓ Branch 0 taken 308 times.
✗ Branch 1 not taken.
308 if(!p_igetw(&tile,f))
10266 {
10267 return qe_invalid;
10268 }
10269
10270
1/2
✓ Branch 0 taken 308 times.
✗ Branch 1 not taken.
308 if(!p_getc(&flip,f))
10271 {
10272 return qe_invalid;
10273 }
10274
10275
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 308 times.
308 if(!p_getc(&extend,f))
10276 {
10277 return qe_invalid;
10278 }
10279
10280 308 chargespr[i][spr_tile]=(int32_t)tile;
10281 308 chargespr[i][spr_flip]=(int32_t)flip;
10282 308 chargespr[i][spr_extend]=(int32_t)extend;
10283 308 }
10284 77 }
10285
10286
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 77 times.
77 if(v_herosprites>4)
10287 {
10288
1/2
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
77 if(!p_getc(&dummy_byte,f))
10289 {
10290 return qe_invalid;
10291 }
10292
10293 77 zinit.hero_swim_speed=(byte)dummy_byte;
10294 77 }
10295
10296 77 memset(frozenspr, 0, sizeof(frozenspr));
10297 77 memset(frozen_waterspr, 0, sizeof(frozen_waterspr));
10298 77 memset(onfirespr, 0, sizeof(onfirespr));
10299 77 memset(onfire_waterspr, 0, sizeof(onfire_waterspr));
10300 77 memset(diggingspr, 0, sizeof(diggingspr));
10301 77 memset(usingrodspr, 0, sizeof(usingrodspr));
10302 77 memset(usingcanespr, 0, sizeof(usingcanespr));
10303 77 memset(pushingspr, 0, sizeof(pushingspr));
10304 77 memset(liftingspr, 0, sizeof(liftingspr));
10305 77 memset(liftingwalkspr, 0, sizeof(liftingwalkspr));
10306 77 memset(stunnedspr, 0, sizeof(stunnedspr));
10307 77 memset(stunned_waterspr, 0, sizeof(stunned_waterspr));
10308 77 memset(fallingspr, 0, sizeof(fallingspr));
10309 77 memset(shockedspr, 0, sizeof(shockedspr));
10310 77 memset(shocked_waterspr, 0, sizeof(shocked_waterspr));
10311 77 memset(pullswordspr, 0, sizeof(pullswordspr));
10312 77 memset(readingspr, 0, sizeof(readingspr));
10313 77 memset(slash180spr, 0, sizeof(slash180spr));
10314 77 memset(slashZ4spr, 0, sizeof(slashZ4spr));
10315 77 memset(dashspr, 0, sizeof(dashspr));
10316 77 memset(bonkspr, 0, sizeof(bonkspr));
10317 77 memset(medallionsprs, 0, sizeof(medallionsprs));
10318 77 memset(holdspr[0][2], 0, sizeof(holdspr[0][2])); //Sword hold (Land)
10319 77 memset(holdspr[1][2], 0, sizeof(holdspr[1][2])); //Sword hold (Water)
10320
2/2
✓ Branch 0 taken 308 times.
✓ Branch 1 taken 77 times.
385 for(int32_t q = 0; q < 4; ++q)
10321 {
10322
2/2
✓ Branch 0 taken 924 times.
✓ Branch 1 taken 308 times.
1232 for(int32_t p = 0; p < 3; ++p)
10323 {
10324 924 drowningspr[q][p] = divespr[q][p];
10325 924 drowning_lavaspr[q][p] = divespr[q][p];
10326 924 }
10327 308 }
10328 77 memset(sideswimspr, 0, sizeof(sideswimspr));
10329 77 memset(sideswimslashspr, 0, sizeof(sideswimslashspr));
10330 77 memset(sideswimstabspr, 0, sizeof(sideswimstabspr));
10331 77 memset(sideswimpoundspr, 0, sizeof(sideswimpoundspr));
10332 77 memset(sideswimchargespr, 0, sizeof(sideswimchargespr));
10333 77 memset(sideswimholdspr, 0, sizeof(sideswimholdspr));
10334 77 memset(sidedrowningspr, 0, sizeof(sidedrowningspr));
10335 77 }
10336
10337
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 97 times.
97 if(FFCore.quest_format[vInitData] < 34)
10338 {
10339 97 bool fastswim = zinit.hero_swim_speed > 60;
10340 // '2/3' or '1/2'
10341 97 zinit.hero_swim_mult = fastswim ? 2 : 1;
10342 97 zinit.hero_swim_div = fastswim ? 3 : 2;
10343 97 }
10344 97 return 0;
10345 97 }
10346
10347 5950 void setSprite(int32_t* arr, int32_t tile, int32_t flip, int32_t ext)
10348 {
10349 5950 arr[spr_tile] = tile;
10350
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5950 times.
5950 arr[spr_flip] = (flip > 3 ? 0 : flip);
10351
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5950 times.
5950 arr[spr_extend] = (ext > 2 ? 0 : ext);
10352 5950 }
10353 //Used to read the player sprites as int32_t, not word.
10354 35 int32_t readherosprites3(PACKFILE *f, int32_t v_herosprites, int32_t cv_herosprites)
10355 {
10356 //these are here to bypass compiler warnings about unused arguments
10357 35 cv_herosprites=cv_herosprites;
10358
10359 35 zinit.hero_swim_speed=67; //default
10360 35 setupherotiles(zinit.heroAnimationStyle);
10361 35 setupherodefenses();
10362 35 setupherooffsets();
10363
10364 int32_t tile, tile2;
10365 byte flip, extend, dummy_byte;
10366
10367
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 35 times.
35 if(v_herosprites>=0)
10368 {
10369
10370
2/2
✓ Branch 0 taken 140 times.
✓ Branch 1 taken 35 times.
175 for(int32_t i=0; i<4; i++)
10371 {
10372
1/2
✓ Branch 0 taken 140 times.
✗ Branch 1 not taken.
140 if(!p_igetl(&tile,f))
10373 {
10374 return qe_invalid;
10375 }
10376
10377
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 140 times.
140 if(!p_getc(&flip,f))
10378 {
10379 return qe_invalid;
10380 }
10381
10382
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 140 times.
140 if(!p_getc(&extend,f))
10383 {
10384 return qe_invalid;
10385 }
10386
10387 140 setSprite(walkspr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10388 140 }
10389
10390
2/2
✓ Branch 0 taken 140 times.
✓ Branch 1 taken 35 times.
175 for(int32_t i=0; i<4; i++)
10391 {
10392
1/2
✓ Branch 0 taken 140 times.
✗ Branch 1 not taken.
140 if(!p_igetl(&tile,f))
10393 {
10394 return qe_invalid;
10395 }
10396
10397
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 140 times.
140 if(!p_getc(&flip,f))
10398 {
10399 return qe_invalid;
10400 }
10401
10402
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 140 times.
140 if(!p_getc(&extend,f))
10403 {
10404 return qe_invalid;
10405 }
10406
10407 140 setSprite(stabspr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10408 140 }
10409
10410
2/2
✓ Branch 0 taken 140 times.
✓ Branch 1 taken 35 times.
175 for(int32_t i=0; i<4; i++)
10411 {
10412
1/2
✓ Branch 0 taken 140 times.
✗ Branch 1 not taken.
140 if(!p_igetl(&tile,f))
10413 {
10414 return qe_invalid;
10415 }
10416
10417
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 140 times.
140 if(!p_getc(&flip,f))
10418 {
10419 return qe_invalid;
10420 }
10421
10422
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 140 times.
140 if(!p_getc(&extend,f))
10423 {
10424 return qe_invalid;
10425 }
10426
10427 140 setSprite(slashspr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10428 140 }
10429
10430
2/2
✓ Branch 0 taken 140 times.
✓ Branch 1 taken 35 times.
175 for(int32_t i=0; i<4; i++)
10431 {
10432
1/2
✓ Branch 0 taken 140 times.
✗ Branch 1 not taken.
140 if(!p_igetl(&tile,f))
10433 {
10434 return qe_invalid;
10435 }
10436
10437
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 140 times.
140 if(!p_getc(&flip,f))
10438 {
10439 return qe_invalid;
10440 }
10441
10442
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 140 times.
140 if(!p_getc(&extend,f))
10443 {
10444 return qe_invalid;
10445 }
10446
10447 140 setSprite(floatspr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10448 140 }
10449
10450
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 35 times.
35 if(v_herosprites>1)
10451 {
10452
2/2
✓ Branch 0 taken 140 times.
✓ Branch 1 taken 35 times.
175 for(int32_t i=0; i<4; i++)
10453 {
10454
1/2
✓ Branch 0 taken 140 times.
✗ Branch 1 not taken.
140 if(!p_igetl(&tile,f))
10455 {
10456 return qe_invalid;
10457 }
10458
10459
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 140 times.
140 if(!p_getc(&flip,f))
10460 {
10461 return qe_invalid;
10462 }
10463
10464
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 140 times.
140 if(!p_getc(&extend,f))
10465 {
10466 return qe_invalid;
10467 }
10468
10469 140 setSprite(swimspr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10470 140 }
10471 35 }
10472
10473
2/2
✓ Branch 0 taken 140 times.
✓ Branch 1 taken 35 times.
175 for(int32_t i=0; i<4; i++)
10474 {
10475
1/2
✓ Branch 0 taken 140 times.
✗ Branch 1 not taken.
140 if(!p_igetl(&tile,f))
10476 {
10477 return qe_invalid;
10478 }
10479
10480
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 140 times.
140 if(!p_getc(&flip,f))
10481 {
10482 return qe_invalid;
10483 }
10484
10485
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 140 times.
140 if(!p_getc(&extend,f))
10486 {
10487 return qe_invalid;
10488 }
10489
10490 140 setSprite(divespr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10491 140 }
10492
10493
2/2
✓ Branch 0 taken 140 times.
✓ Branch 1 taken 35 times.
175 for(int32_t i=0; i<4; i++)
10494 {
10495
1/2
✓ Branch 0 taken 140 times.
✗ Branch 1 not taken.
140 if(!p_igetl(&tile,f))
10496 {
10497 return qe_invalid;
10498 }
10499
10500
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 140 times.
140 if(!p_getc(&flip,f))
10501 {
10502 return qe_invalid;
10503 }
10504
10505
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 140 times.
140 if(!p_getc(&extend,f))
10506 {
10507 return qe_invalid;
10508 }
10509
10510 140 setSprite(poundspr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10511 140 }
10512
10513
1/2
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
35 if(!p_igetl(&tile,f))
10514 {
10515 return qe_invalid;
10516 }
10517
10518 35 flip=0;
10519
10520
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 35 times.
35 if(v_herosprites>0)
10521 {
10522
1/2
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
35 if(!p_getc(&flip,f))
10523 {
10524 return qe_invalid;
10525 }
10526 35 }
10527
10528
1/2
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
35 if(!p_getc(&extend,f))
10529 {
10530 return qe_invalid;
10531 }
10532
10533 35 setSprite(castingspr, int32_t(tile), int32_t(flip), int32_t(extend));
10534
10535
1/2
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
35 if(v_herosprites>0)
10536 {
10537 35 int32_t num_holdsprs = (v_herosprites > 6 ? 3 : 2);
10538
2/2
✓ Branch 0 taken 70 times.
✓ Branch 1 taken 35 times.
105 for(int32_t i=0; i<2; i++)
10539 {
10540
2/2
✓ Branch 0 taken 210 times.
✓ Branch 1 taken 70 times.
280 for(int32_t j=0; j<num_holdsprs; j++)
10541 {
10542
1/2
✓ Branch 0 taken 210 times.
✗ Branch 1 not taken.
210 if(!p_igetl(&tile,f))
10543 {
10544 return qe_invalid;
10545 }
10546
10547
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 210 times.
210 if(!p_getc(&flip,f))
10548 {
10549 return qe_invalid;
10550 }
10551
10552
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 210 times.
210 if(!p_getc(&extend,f))
10553 {
10554 return qe_invalid;
10555 }
10556
10557 210 setSprite(holdspr[i][j], int32_t(tile), int32_t(flip), int32_t(extend));
10558 210 }
10559 70 }
10560 35 }
10561 else
10562 {
10563 for(int32_t i=0; i<2; i++)
10564 {
10565 if(!p_igetl(&tile,f))
10566 {
10567 return qe_invalid;
10568 }
10569
10570 if(!p_igetl(&tile2,f))
10571 {
10572 return qe_invalid;
10573 }
10574
10575 if(!p_getc(&extend,f))
10576 {
10577 return qe_invalid;
10578 }
10579
10580 setSprite(holdspr[i][spr_hold1], int32_t(tile), int32_t(flip), int32_t(extend));
10581 setSprite(holdspr[i][spr_hold2], int32_t(tile2), int32_t(flip), int32_t(extend));
10582 }
10583 }
10584
10585
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 35 times.
35 if(v_herosprites>2)
10586 {
10587
2/2
✓ Branch 0 taken 140 times.
✓ Branch 1 taken 35 times.
175 for(int32_t i=0; i<4; i++)
10588 {
10589
1/2
✓ Branch 0 taken 140 times.
✗ Branch 1 not taken.
140 if(!p_igetl(&tile,f))
10590 {
10591 return qe_invalid;
10592 }
10593
10594
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 140 times.
140 if(!p_getc(&flip,f))
10595 {
10596 return qe_invalid;
10597 }
10598
10599
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 140 times.
140 if(!p_getc(&extend,f))
10600 {
10601 return qe_invalid;
10602 }
10603
10604 140 setSprite(jumpspr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10605 140 }
10606 35 }
10607
10608
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 35 times.
35 if(v_herosprites>3)
10609 {
10610
2/2
✓ Branch 0 taken 140 times.
✓ Branch 1 taken 35 times.
175 for(int32_t i=0; i<4; i++)
10611 {
10612
1/2
✓ Branch 0 taken 140 times.
✗ Branch 1 not taken.
140 if(!p_igetl(&tile,f))
10613 {
10614 return qe_invalid;
10615 }
10616
10617
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 140 times.
140 if(!p_getc(&flip,f))
10618 {
10619 return qe_invalid;
10620 }
10621
10622
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 140 times.
140 if(!p_getc(&extend,f))
10623 {
10624 return qe_invalid;
10625 }
10626
10627 140 setSprite(chargespr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10628 140 }
10629 35 }
10630
10631
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 35 times.
35 if(v_herosprites>4)
10632 {
10633
1/2
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
35 if(!p_getc(&dummy_byte,f))
10634 {
10635 return qe_invalid;
10636 }
10637
10638 35 zinit.hero_swim_speed=(byte)dummy_byte;
10639 35 }
10640
10641
1/2
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
35 if(v_herosprites>6)
10642 {
10643
2/2
✓ Branch 0 taken 140 times.
✓ Branch 1 taken 35 times.
175 for(int32_t q = 0; q < 4; ++q)
10644 {
10645
1/2
✓ Branch 0 taken 140 times.
✗ Branch 1 not taken.
140 if(!p_igetl(&tile,f))
10646 return qe_invalid;
10647
10648
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 140 times.
140 if(!p_getc(&flip,f))
10649 return qe_invalid;
10650
10651
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 140 times.
140 if(!p_getc(&extend,f))
10652 return qe_invalid;
10653
10654 140 setSprite(frozenspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10655 140 }
10656
2/2
✓ Branch 0 taken 140 times.
✓ Branch 1 taken 35 times.
175 for(int32_t q = 0; q < 4; ++q)
10657 {
10658
1/2
✓ Branch 0 taken 140 times.
✗ Branch 1 not taken.
140 if(!p_igetl(&tile,f))
10659 return qe_invalid;
10660
10661
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 140 times.
140 if(!p_getc(&flip,f))
10662 return qe_invalid;
10663
10664
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 140 times.
140 if(!p_getc(&extend,f))
10665 return qe_invalid;
10666
10667 140 setSprite(frozen_waterspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10668 140 }
10669
10670
2/2
✓ Branch 0 taken 140 times.
✓ Branch 1 taken 35 times.
175 for(int32_t q = 0; q < 4; ++q)
10671 {
10672
1/2
✓ Branch 0 taken 140 times.
✗ Branch 1 not taken.
140 if(!p_igetl(&tile,f))
10673 return qe_invalid;
10674
10675
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 140 times.
140 if(!p_getc(&flip,f))
10676 return qe_invalid;
10677
10678
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 140 times.
140 if(!p_getc(&extend,f))
10679 return qe_invalid;
10680
10681 140 setSprite(onfirespr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10682 140 }
10683
2/2
✓ Branch 0 taken 140 times.
✓ Branch 1 taken 35 times.
175 for(int32_t q = 0; q < 4; ++q)
10684 {
10685
1/2
✓ Branch 0 taken 140 times.
✗ Branch 1 not taken.
140 if(!p_igetl(&tile,f))
10686 return qe_invalid;
10687
10688
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 140 times.
140 if(!p_getc(&flip,f))
10689 return qe_invalid;
10690
10691
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 140 times.
140 if(!p_getc(&extend,f))
10692 return qe_invalid;
10693
10694 140 setSprite(onfire_waterspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10695 140 }
10696
10697
2/2
✓ Branch 0 taken 140 times.
✓ Branch 1 taken 35 times.
175 for(int32_t q = 0; q < 4; ++q)
10698 {
10699
1/2
✓ Branch 0 taken 140 times.
✗ Branch 1 not taken.
140 if(!p_igetl(&tile,f))
10700 return qe_invalid;
10701
10702
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 140 times.
140 if(!p_getc(&flip,f))
10703 return qe_invalid;
10704
10705
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 140 times.
140 if(!p_getc(&extend,f))
10706 return qe_invalid;
10707
10708 140 setSprite(diggingspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10709 140 }
10710
10711
2/2
✓ Branch 0 taken 140 times.
✓ Branch 1 taken 35 times.
175 for(int32_t q = 0; q < 4; ++q)
10712 {
10713
1/2
✓ Branch 0 taken 140 times.
✗ Branch 1 not taken.
140 if(!p_igetl(&tile,f))
10714 return qe_invalid;
10715
10716
1/2
✓ Branch 0 taken 140 times.
✗ Branch 1 not taken.
140 if(!p_getc(&flip,f))
10717 return qe_invalid;
10718
10719
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 140 times.
140 if(!p_getc(&extend,f))
10720 return qe_invalid;
10721
10722 140 setSprite(usingrodspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10723 140 }
10724
10725
2/2
✓ Branch 0 taken 140 times.
✓ Branch 1 taken 35 times.
175 for(int32_t q = 0; q < 4; ++q)
10726 {
10727
1/2
✓ Branch 0 taken 140 times.
✗ Branch 1 not taken.
140 if(!p_igetl(&tile,f))
10728 return qe_invalid;
10729
10730
1/2
✓ Branch 0 taken 140 times.
✗ Branch 1 not taken.
140 if(!p_getc(&flip,f))
10731 return qe_invalid;
10732
10733
1/2
✓ Branch 0 taken 140 times.
✗ Branch 1 not taken.
140 if(!p_getc(&extend,f))
10734 return qe_invalid;
10735
10736 140 setSprite(usingcanespr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10737 140 }
10738
10739
2/2
✓ Branch 0 taken 140 times.
✓ Branch 1 taken 35 times.
175 for(int32_t q = 0; q < 4; ++q)
10740 {
10741
1/2
✓ Branch 0 taken 140 times.
✗ Branch 1 not taken.
140 if(!p_igetl(&tile,f))
10742 return qe_invalid;
10743
10744
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 140 times.
140 if(!p_getc(&flip,f))
10745 return qe_invalid;
10746
10747
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 140 times.
140 if(!p_getc(&extend,f))
10748 return qe_invalid;
10749
10750 140 setSprite(pushingspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10751 140 }
10752
10753
2/2
✓ Branch 0 taken 140 times.
✓ Branch 1 taken 35 times.
175 for(int32_t q = 0; q < 4; ++q)
10754 {
10755
1/2
✓ Branch 0 taken 140 times.
✗ Branch 1 not taken.
140 if(!p_igetl(&tile,f))
10756 return qe_invalid;
10757
10758
1/2
✓ Branch 0 taken 140 times.
✗ Branch 1 not taken.
140 if(!p_getc(&flip,f))
10759 return qe_invalid;
10760
10761
1/2
✓ Branch 0 taken 140 times.
✗ Branch 1 not taken.
140 if(!p_getc(&extend,f))
10762 return qe_invalid;
10763
10764 140 byte frames = 0;
10765
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 132 times.
140 if(v_herosprites > 15)
10766 {
10767
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 132 times.
132 if(!p_getc(&frames,f))
10768 return qe_invalid;
10769 132 }
10770
10771 140 setSprite(liftingspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10772 140 liftingspr[q][spr_frames] = frames;
10773 140 }
10774
10775
2/2
✓ Branch 0 taken 140 times.
✓ Branch 1 taken 35 times.
175 for(int32_t q = 0; q < 4; ++q)
10776 {
10777
1/2
✓ Branch 0 taken 140 times.
✗ Branch 1 not taken.
140 if(!p_igetl(&tile,f))
10778 return qe_invalid;
10779
10780
1/2
✓ Branch 0 taken 140 times.
✗ Branch 1 not taken.
140 if(!p_getc(&flip,f))
10781 return qe_invalid;
10782
10783
1/2
✓ Branch 0 taken 140 times.
✗ Branch 1 not taken.
140 if(!p_getc(&extend,f))
10784 return qe_invalid;
10785
10786 140 setSprite(liftingwalkspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10787 140 }
10788
10789
2/2
✓ Branch 0 taken 140 times.
✓ Branch 1 taken 35 times.
175 for(int32_t q = 0; q < 4; ++q)
10790 {
10791
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 140 times.
140 if(!p_igetl(&tile,f))
10792 return qe_invalid;
10793
10794
1/2
✓ Branch 0 taken 140 times.
✗ Branch 1 not taken.
140 if(!p_getc(&flip,f))
10795 return qe_invalid;
10796
10797
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 140 times.
140 if(!p_getc(&extend,f))
10798 return qe_invalid;
10799
10800 140 setSprite(stunnedspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10801 140 }
10802
2/2
✓ Branch 0 taken 140 times.
✓ Branch 1 taken 35 times.
175 for(int32_t q = 0; q < 4; ++q)
10803 {
10804
1/2
✓ Branch 0 taken 140 times.
✗ Branch 1 not taken.
140 if(!p_igetl(&tile,f))
10805 return qe_invalid;
10806
10807
1/2
✓ Branch 0 taken 140 times.
✗ Branch 1 not taken.
140 if(!p_getc(&flip,f))
10808 return qe_invalid;
10809
10810
1/2
✓ Branch 0 taken 140 times.
✗ Branch 1 not taken.
140 if(!p_getc(&extend,f))
10811 return qe_invalid;
10812
10813 140 setSprite(stunned_waterspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10814 140 }
10815
10816
2/2
✓ Branch 0 taken 140 times.
✓ Branch 1 taken 35 times.
175 for(int32_t q = 0; q < 4; ++q)
10817 {
10818
1/2
✓ Branch 0 taken 140 times.
✗ Branch 1 not taken.
140 if(!p_igetl(&tile,f))
10819 return qe_invalid;
10820
10821
1/2
✓ Branch 0 taken 140 times.
✗ Branch 1 not taken.
140 if(!p_getc(&flip,f))
10822 return qe_invalid;
10823
10824
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 140 times.
140 if(!p_getc(&extend,f))
10825 return qe_invalid;
10826
10827 140 setSprite(drowningspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10828 140 }
10829
10830
2/2
✓ Branch 0 taken 140 times.
✓ Branch 1 taken 35 times.
175 for(int32_t q = 0; q < 4; ++q)
10831 {
10832
1/2
✓ Branch 0 taken 140 times.
✗ Branch 1 not taken.
140 if(!p_igetl(&tile,f))
10833 return qe_invalid;
10834
10835
1/2
✓ Branch 0 taken 140 times.
✗ Branch 1 not taken.
140 if(!p_getc(&flip,f))
10836 return qe_invalid;
10837
10838
1/2
✓ Branch 0 taken 140 times.
✗ Branch 1 not taken.
140 if(!p_getc(&extend,f))
10839 return qe_invalid;
10840
10841 140 setSprite(drowning_lavaspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10842 140 }
10843
10844
2/2
✓ Branch 0 taken 140 times.
✓ Branch 1 taken 35 times.
175 for(int32_t q = 0; q < 4; ++q)
10845 {
10846
1/2
✓ Branch 0 taken 140 times.
✗ Branch 1 not taken.
140 if(!p_igetl(&tile,f))
10847 return qe_invalid;
10848
10849
1/2
✓ Branch 0 taken 140 times.
✗ Branch 1 not taken.
140 if(!p_getc(&flip,f))
10850 return qe_invalid;
10851
10852
1/2
✓ Branch 0 taken 140 times.
✗ Branch 1 not taken.
140 if(!p_getc(&extend,f))
10853 return qe_invalid;
10854
10855 140 setSprite(fallingspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10856 140 }
10857
10858
2/2
✓ Branch 0 taken 140 times.
✓ Branch 1 taken 35 times.
175 for(int32_t q = 0; q < 4; ++q)
10859 {
10860
1/2
✓ Branch 0 taken 140 times.
✗ Branch 1 not taken.
140 if(!p_igetl(&tile,f))
10861 return qe_invalid;
10862
10863
1/2
✓ Branch 0 taken 140 times.
✗ Branch 1 not taken.
140 if(!p_getc(&flip,f))
10864 return qe_invalid;
10865
10866
1/2
✓ Branch 0 taken 140 times.
✗ Branch 1 not taken.
140 if(!p_getc(&extend,f))
10867 return qe_invalid;
10868
10869 140 setSprite(shockedspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10870 140 }
10871
2/2
✓ Branch 0 taken 140 times.
✓ Branch 1 taken 35 times.
175 for(int32_t q = 0; q < 4; ++q)
10872 {
10873
1/2
✓ Branch 0 taken 140 times.
✗ Branch 1 not taken.
140 if(!p_igetl(&tile,f))
10874 return qe_invalid;
10875
10876
1/2
✓ Branch 0 taken 140 times.
✗ Branch 1 not taken.
140 if(!p_getc(&flip,f))
10877 return qe_invalid;
10878
10879
1/2
✓ Branch 0 taken 140 times.
✗ Branch 1 not taken.
140 if(!p_getc(&extend,f))
10880 return qe_invalid;
10881
10882 140 setSprite(shocked_waterspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10883 140 }
10884
10885
2/2
✓ Branch 0 taken 140 times.
✓ Branch 1 taken 35 times.
175 for(int32_t q = 0; q < 4; ++q)
10886 {
10887
1/2
✓ Branch 0 taken 140 times.
✗ Branch 1 not taken.
140 if(!p_igetl(&tile,f))
10888 return qe_invalid;
10889
10890
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 140 times.
140 if(!p_getc(&flip,f))
10891 return qe_invalid;
10892
10893
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 140 times.
140 if(!p_getc(&extend,f))
10894 return qe_invalid;
10895
10896 140 setSprite(pullswordspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10897 140 }
10898
10899
2/2
✓ Branch 0 taken 140 times.
✓ Branch 1 taken 35 times.
175 for(int32_t q = 0; q < 4; ++q)
10900 {
10901
1/2
✓ Branch 0 taken 140 times.
✗ Branch 1 not taken.
140 if(!p_igetl(&tile,f))
10902 return qe_invalid;
10903
10904
1/2
✓ Branch 0 taken 140 times.
✗ Branch 1 not taken.
140 if(!p_getc(&flip,f))
10905 return qe_invalid;
10906
10907
1/2
✓ Branch 0 taken 140 times.
✗ Branch 1 not taken.
140 if(!p_getc(&extend,f))
10908 return qe_invalid;
10909
10910 140 setSprite(readingspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10911 140 }
10912
10913
2/2
✓ Branch 0 taken 140 times.
✓ Branch 1 taken 35 times.
175 for(int32_t q = 0; q < 4; ++q)
10914 {
10915
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 140 times.
140 if(!p_igetl(&tile,f))
10916 return qe_invalid;
10917
10918
1/2
✓ Branch 0 taken 140 times.
✗ Branch 1 not taken.
140 if(!p_getc(&flip,f))
10919 return qe_invalid;
10920
10921
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 140 times.
140 if(!p_getc(&extend,f))
10922 return qe_invalid;
10923
10924 140 setSprite(slash180spr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10925 140 }
10926
10927
2/2
✓ Branch 0 taken 140 times.
✓ Branch 1 taken 35 times.
175 for(int32_t q = 0; q < 4; ++q)
10928 {
10929
1/2
✓ Branch 0 taken 140 times.
✗ Branch 1 not taken.
140 if(!p_igetl(&tile,f))
10930 return qe_invalid;
10931
10932
1/2
✓ Branch 0 taken 140 times.
✗ Branch 1 not taken.
140 if(!p_getc(&flip,f))
10933 return qe_invalid;
10934
10935
1/2
✓ Branch 0 taken 140 times.
✗ Branch 1 not taken.
140 if(!p_getc(&extend,f))
10936 return qe_invalid;
10937
10938 140 setSprite(slashZ4spr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10939 140 }
10940
10941
2/2
✓ Branch 0 taken 140 times.
✓ Branch 1 taken 35 times.
175 for(int32_t q = 0; q < 4; ++q)
10942 {
10943
1/2
✓ Branch 0 taken 140 times.
✗ Branch 1 not taken.
140 if(!p_igetl(&tile,f))
10944 return qe_invalid;
10945
10946
1/2
✓ Branch 0 taken 140 times.
✗ Branch 1 not taken.
140 if(!p_getc(&flip,f))
10947 return qe_invalid;
10948
10949
1/2
✓ Branch 0 taken 140 times.
✗ Branch 1 not taken.
140 if(!p_getc(&extend,f))
10950 return qe_invalid;
10951
10952 140 setSprite(dashspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10953 140 }
10954
10955
2/2
✓ Branch 0 taken 140 times.
✓ Branch 1 taken 35 times.
175 for(int32_t q = 0; q < 4; ++q)
10956 {
10957
1/2
✓ Branch 0 taken 140 times.
✗ Branch 1 not taken.
140 if(!p_igetl(&tile,f))
10958 return qe_invalid;
10959
10960
1/2
✓ Branch 0 taken 140 times.
✗ Branch 1 not taken.
140 if(!p_getc(&flip,f))
10961 return qe_invalid;
10962
10963
1/2
✓ Branch 0 taken 140 times.
✗ Branch 1 not taken.
140 if(!p_getc(&extend,f))
10964 return qe_invalid;
10965
10966 140 setSprite(bonkspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10967 140 }
10968
10969
2/2
✓ Branch 0 taken 105 times.
✓ Branch 1 taken 35 times.
140 for(int32_t q = 0; q < 3; ++q) //Not directions; number of medallion sprs
10970 {
10971
1/2
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
105 if(!p_igetl(&tile,f))
10972 return qe_invalid;
10973
10974
1/2
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
105 if(!p_getc(&flip,f))
10975 return qe_invalid;
10976
10977
1/2
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
105 if(!p_getc(&extend,f))
10978 return qe_invalid;
10979
10980 105 setSprite(medallionsprs[q], int32_t(tile), int32_t(flip), int32_t(extend));
10981 105 }
10982 35 }
10983 else
10984 {
10985 memset(frozenspr, 0, sizeof(frozenspr));
10986 memset(frozen_waterspr, 0, sizeof(frozen_waterspr));
10987 memset(onfirespr, 0, sizeof(onfirespr));
10988 memset(onfire_waterspr, 0, sizeof(onfire_waterspr));
10989 memset(diggingspr, 0, sizeof(diggingspr));
10990 memset(usingrodspr, 0, sizeof(usingrodspr));
10991 memset(usingcanespr, 0, sizeof(usingcanespr));
10992 memset(pushingspr, 0, sizeof(pushingspr));
10993 memset(liftingspr, 0, sizeof(liftingspr));
10994 memset(liftingwalkspr, 0, sizeof(liftingwalkspr));
10995 memset(stunnedspr, 0, sizeof(stunnedspr));
10996 memset(stunned_waterspr, 0, sizeof(stunned_waterspr));
10997 memset(fallingspr, 0, sizeof(fallingspr));
10998 memset(shockedspr, 0, sizeof(shockedspr));
10999 memset(shocked_waterspr, 0, sizeof(shocked_waterspr));
11000 memset(pullswordspr, 0, sizeof(pullswordspr));
11001 memset(readingspr, 0, sizeof(readingspr));
11002 memset(slash180spr, 0, sizeof(slash180spr));
11003 memset(slashZ4spr, 0, sizeof(slashZ4spr));
11004 memset(dashspr, 0, sizeof(dashspr));
11005 memset(bonkspr, 0, sizeof(bonkspr));
11006 memset(medallionsprs, 0, sizeof(medallionsprs));
11007 memset(holdspr[0][2], 0, sizeof(holdspr[0][2])); //Sword hold (Land)
11008 memset(holdspr[1][2], 0, sizeof(holdspr[1][2])); //Sword hold (Water)
11009 for(int32_t q = 0; q < 4; ++q)
11010 {
11011 for(int32_t p = 0; p < 3; ++p)
11012 {
11013 drowningspr[q][p] = divespr[q][p];
11014 drowning_lavaspr[q][p] = divespr[q][p];
11015 }
11016 }
11017 }
11018
1/2
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
35 if (v_herosprites > 8)
11019 {
11020
2/2
✓ Branch 0 taken 140 times.
✓ Branch 1 taken 35 times.
175 for(int32_t q = 0; q < 4; ++q)
11021 {
11022
1/2
✓ Branch 0 taken 140 times.
✗ Branch 1 not taken.
140 if(!p_igetl(&tile,f))
11023 return qe_invalid;
11024
11025
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 140 times.
140 if(!p_getc(&flip,f))
11026 return qe_invalid;
11027
11028
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 140 times.
140 if(!p_getc(&extend,f))
11029 return qe_invalid;
11030
11031 140 setSprite(sideswimspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11032 140 }
11033 35 }
11034 else
11035 {
11036 memset(sideswimspr, 0, sizeof(sideswimspr));
11037 }
11038
1/2
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
35 if (v_herosprites > 9)
11039 {
11040
2/2
✓ Branch 0 taken 140 times.
✓ Branch 1 taken 35 times.
175 for(int32_t q = 0; q < 4; ++q)
11041 {
11042
1/2
✓ Branch 0 taken 140 times.
✗ Branch 1 not taken.
140 if(!p_igetl(&tile,f))
11043 return qe_invalid;
11044
11045
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 140 times.
140 if(!p_getc(&flip,f))
11046 return qe_invalid;
11047
11048
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 140 times.
140 if(!p_getc(&extend,f))
11049 return qe_invalid;
11050
11051 140 setSprite(sideswimslashspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11052 140 }
11053
2/2
✓ Branch 0 taken 140 times.
✓ Branch 1 taken 35 times.
175 for(int32_t q = 0; q < 4; ++q)
11054 {
11055
1/2
✓ Branch 0 taken 140 times.
✗ Branch 1 not taken.
140 if(!p_igetl(&tile,f))
11056 return qe_invalid;
11057
11058
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 140 times.
140 if(!p_getc(&flip,f))
11059 return qe_invalid;
11060
11061
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 140 times.
140 if(!p_getc(&extend,f))
11062 return qe_invalid;
11063
11064 140 setSprite(sideswimstabspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11065 140 }
11066
2/2
✓ Branch 0 taken 140 times.
✓ Branch 1 taken 35 times.
175 for(int32_t q = 0; q < 4; ++q)
11067 {
11068
1/2
✓ Branch 0 taken 140 times.
✗ Branch 1 not taken.
140 if(!p_igetl(&tile,f))
11069 return qe_invalid;
11070
11071
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 140 times.
140 if(!p_getc(&flip,f))
11072 return qe_invalid;
11073
11074
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 140 times.
140 if(!p_getc(&extend,f))
11075 return qe_invalid;
11076
11077 140 setSprite(sideswimpoundspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11078 140 }
11079
2/2
✓ Branch 0 taken 140 times.
✓ Branch 1 taken 35 times.
175 for(int32_t q = 0; q < 4; ++q)
11080 {
11081
1/2
✓ Branch 0 taken 140 times.
✗ Branch 1 not taken.
140 if(!p_igetl(&tile,f))
11082 return qe_invalid;
11083
11084
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 140 times.
140 if(!p_getc(&flip,f))
11085 return qe_invalid;
11086
11087
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 140 times.
140 if(!p_getc(&extend,f))
11088 return qe_invalid;
11089
11090 140 setSprite(sideswimchargespr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11091 140 }
11092 35 }
11093 else
11094 {
11095 memset(sideswimslashspr, 0, sizeof(sideswimslashspr));
11096 memset(sideswimstabspr, 0, sizeof(sideswimstabspr));
11097 memset(sideswimpoundspr, 0, sizeof(sideswimpoundspr));
11098 memset(sideswimchargespr, 0, sizeof(sideswimchargespr));
11099 }
11100
1/2
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
35 if (v_herosprites > 10)
11101 {
11102
2/2
✓ Branch 0 taken 140 times.
✓ Branch 1 taken 35 times.
175 for(int32_t q = 0; q < 4; ++q)
11103 {
11104 int32_t hmr;
11105
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 140 times.
140 if(!p_igetl(&hmr,f))
11106 return qe_invalid;
11107
11108 140 hammeroffsets[q] = hmr;
11109 140 }
11110 35 }
11111 else
11112 {
11113 for(int32_t q = 0; q < 4; ++q) hammeroffsets[q] = 0;
11114 }
11115
1/2
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
35 if (v_herosprites > 11)
11116 {
11117
2/2
✓ Branch 0 taken 105 times.
✓ Branch 1 taken 35 times.
140 for(int32_t q = 0; q < 3; ++q)
11118 {
11119
1/2
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
105 if(!p_igetl(&tile,f))
11120 return qe_invalid;
11121
11122
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 105 times.
105 if(!p_getc(&flip,f))
11123 return qe_invalid;
11124
11125
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 105 times.
105 if(!p_getc(&extend,f))
11126 return qe_invalid;
11127
11128 105 setSprite(sideswimholdspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11129 105 }
11130 35 }
11131 else
11132 {
11133 memset(sideswimholdspr, 0, sizeof(sideswimholdspr));
11134 }
11135
1/2
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
35 if (v_herosprites > 12)
11136 {
11137
1/2
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
35 if(!p_igetl(&tile,f))
11138 return qe_invalid;
11139
11140
1/2
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
35 if(!p_getc(&flip,f))
11141 return qe_invalid;
11142
11143
1/2
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
35 if(!p_getc(&extend,f))
11144 return qe_invalid;
11145 35 setSprite(sideswimcastingspr, int32_t(tile), int32_t(flip), int32_t(extend));
11146
11147 35 }
11148 else
11149 {
11150 memset(sideswimcastingspr, 0, sizeof(sideswimcastingspr));
11151 }
11152
1/2
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
35 if (v_herosprites > 13)
11153 {
11154
2/2
✓ Branch 0 taken 140 times.
✓ Branch 1 taken 35 times.
175 for(int32_t q = 0; q < 4; ++q)
11155 {
11156
1/2
✓ Branch 0 taken 140 times.
✗ Branch 1 not taken.
140 if(!p_igetl(&tile,f))
11157 return qe_invalid;
11158
11159
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 140 times.
140 if(!p_getc(&flip,f))
11160 return qe_invalid;
11161
11162
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 140 times.
140 if(!p_getc(&extend,f))
11163 return qe_invalid;
11164
11165 140 setSprite(sidedrowningspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11166 140 }
11167 35 }
11168 else
11169 {
11170 memset(sidedrowningspr, 0, sizeof(sidedrowningspr));
11171 }
11172
1/2
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
35 if (v_herosprites > 14)
11173 {
11174
2/2
✓ Branch 0 taken 140 times.
✓ Branch 1 taken 35 times.
175 for(int32_t q = 0; q < 4; ++q)
11175 {
11176
1/2
✓ Branch 0 taken 140 times.
✗ Branch 1 not taken.
140 if(!p_igetl(&tile,f))
11177 return qe_invalid;
11178
11179
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 140 times.
140 if(!p_getc(&flip,f))
11180 return qe_invalid;
11181
11182
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 140 times.
140 if(!p_getc(&extend,f))
11183 return qe_invalid;
11184
11185 140 setSprite(revslashspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11186 140 }
11187 35 }
11188 else
11189 {
11190 memset(revslashspr, 0, sizeof(revslashspr));
11191 }
11192
1/2
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
35 if (v_herosprites > 7)
11193 {
11194 35 int32_t num_defense = wMax;
11195 35 byte def = 0;
11196
11197 //Set num_defense accordingly if changes to enum require version upgrade - Jman
11198 /*if(v_herosprites > [x])
11199 * {
11200 * num_defense = 146 //value of wMax on version 8
11201 * }
11202 */
11203
11204
2/2
✓ Branch 0 taken 5110 times.
✓ Branch 1 taken 35 times.
5145 for (int32_t q = 0; q < num_defense; q++)
11205 {
11206
1/2
✓ Branch 0 taken 5110 times.
✗ Branch 1 not taken.
5110 if (!p_getc(&def, f))
11207 return qe_invalid;
11208
11209 5110 hero_defence[q] = def;
11210 5110 }
11211 35 }
11212 else
11213 {
11214 int32_t num_defense = wMax;
11215 for (int32_t q = 0; q < num_defense; q++)
11216 {
11217 hero_defence[q] = 0;
11218 }
11219 }
11220 35 }
11221
11222
2/2
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 5 times.
35 if(FFCore.quest_format[vInitData] < 34)
11223 {
11224 5 bool fastswim = zinit.hero_swim_speed > 60;
11225 // '2/3' or '1/2'
11226 5 zinit.hero_swim_mult = fastswim ? 2 : 1;
11227 5 zinit.hero_swim_div = fastswim ? 3 : 2;
11228 5 }
11229 35 return 0;
11230 35 }
11231
11232
11233 112 int32_t readherosprites(PACKFILE *f, zquestheader *Header)
11234 {
11235 //these are here to bypass compiler warnings about unused arguments
11236 112 Header=Header;
11237
11238 dword dummy;
11239 112 word s_version=0, s_cversion=0;
11240
11241 //section version info
11242
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 112 times.
112 if(!p_igetw(&s_version,f))
11243 {
11244 return qe_invalid;
11245 }
11246
11247 112 FFCore.quest_format[vHeroSprites] = s_version;
11248
11249 //al_trace("Player sprites version %d\n", s_version);
11250
1/2
✓ Branch 0 taken 112 times.
✗ Branch 1 not taken.
112 if(!p_igetw(&s_cversion,f))
11251 {
11252 return qe_invalid;
11253 }
11254
11255 //section size
11256
1/2
✓ Branch 0 taken 112 times.
✗ Branch 1 not taken.
112 if(!p_igetl(&dummy,f))
11257 {
11258 return qe_invalid;
11259 }
11260
2/2
✓ Branch 0 taken 35 times.
✓ Branch 1 taken 77 times.
112 if ( s_version >= 6 )
11261 {
11262 //al_trace("Reading Player Sprites v6\n");
11263 35 return readherosprites3(f, s_version, dummy);
11264 }
11265 77 else return readherosprites2(f, s_version, dummy);
11266 112 }
11267
11268 86 int32_t read_old_subscreens(PACKFILE *f, word s_version)
11269 {
11270 86 subscreens_active.clear();
11271 86 subscreens_passive.clear();
11272 86 subscreens_overlay.clear();
11273
2/2
✓ Branch 0 taken 11008 times.
✓ Branch 1 taken 86 times.
11094 for(int32_t i=0; i<MAXCUSTOMSUBSCREENS; i++)
11274 {
11275 subscreen_group g;
11276 11008 memset(&g,0,sizeof(subscreen_group));
11277 11008 int32_t ret = read_one_old_subscreen(f, &g, s_version);
11278
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11008 times.
11008 if(ret!=0)
11279 return ret;
11280
2/2
✓ Branch 0 taken 395 times.
✓ Branch 1 taken 10613 times.
11008 if(g.objects[0].type == ssoNULL) continue;
11281
2/2
✓ Branch 0 taken 188 times.
✓ Branch 1 taken 207 times.
395 auto& vec = g.ss_type == sstPASSIVE ? subscreens_passive : subscreens_active;
11282 395 ZCSubscreen& sub = vec.emplace_back();
11283 395 sub.load_old(g);
11284 395 }
11285
11286 86 return 0;
11287 86 }
11288
11289 11008 int32_t read_one_old_subscreen(PACKFILE *f, subscreen_group* g, word s_version)
11290 {
11291 11008 int32_t numsub=0;
11292 11008 byte temp_ss=0;
11293 subscreen_object temp_sub_stack;
11294 11008 subscreen_object *temp_sub = &temp_sub_stack;
11295
11296 char tempname[64];
11297
11298 // FWIW I never saw anything bigger than 20.
11299 #define MAX_DP1_LEN 1024
11300 char tempdp1[MAX_DP1_LEN];
11301
11302
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11008 times.
11008 if(!pfread(tempname,64,f))
11303 {
11304 return qe_invalid;
11305 }
11306
11307
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11008 times.
11008 if(s_version > 1)
11308 {
11309
1/2
✓ Branch 0 taken 11008 times.
✗ Branch 1 not taken.
11008 if(!p_getc(&temp_ss,f))
11310 {
11311 return qe_invalid;
11312 }
11313 11008 }
11314
11315
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11008 times.
11008 if(s_version < 4)
11316 {
11317 uint8_t tmp=0;
11318
11319 if(!p_getc(&tmp,f))
11320 {
11321 return qe_invalid;
11322 }
11323
11324 numsub = (int32_t)tmp;
11325 }
11326 else
11327 {
11328 word tmp;
11329
11330
1/2
✓ Branch 0 taken 11008 times.
✗ Branch 1 not taken.
11008 if(!p_igetw(&tmp, f))
11331 {
11332 return qe_invalid;
11333 }
11334
11335 11008 numsub = (int32_t)tmp;
11336 }
11337
11338 int32_t j;
11339
11340
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 24251 times.
✓ Branch 2 taken 13243 times.
✓ Branch 3 taken 11008 times.
24251 for(j=0; (j<MAXSUBSCREENITEMS&&j<numsub); j++)
11341 {
11342 13243 memset(temp_sub,0,sizeof(subscreen_object));
11343
11344
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13243 times.
13243 switch(g->objects[j].type)
11345 {
11346 case ssoTEXT:
11347 case ssoTEXTBOX:
11348 case ssoCURRENTITEMTEXT:
11349 case ssoCURRENTITEMCLASSTEXT:
11350 if(g->objects[j].dp1 != NULL) delete [](char *)g->objects[j].dp1;
11351
11352 //fall through
11353 default:
11354 13243 memset(&g->objects[j],0,sizeof(subscreen_object));
11355 13243 break;
11356 }
11357
11358
1/2
✓ Branch 0 taken 13243 times.
✗ Branch 1 not taken.
13243 if(!p_getc(&(temp_sub->type),f))
11359 return qe_invalid;
11360
11361
1/2
✓ Branch 0 taken 13243 times.
✗ Branch 1 not taken.
13243 if(!p_getc(&(temp_sub->pos),f))
11362 return qe_invalid;
11363
11364
1/2
✓ Branch 0 taken 13243 times.
✗ Branch 1 not taken.
13243 if(s_version < 5)
11365 {
11366 switch(temp_sub->pos)
11367 {
11368 case 0:
11369 temp_sub->pos = sspUP | sspDOWN | sspSCROLLING;
11370 break;
11371
11372 case 1:
11373 temp_sub->pos = sspUP;
11374 break;
11375
11376 case 2:
11377 temp_sub->pos = sspDOWN;
11378 break;
11379
11380 default:
11381 temp_sub->pos = 0;
11382 }
11383 }
11384
11385
1/2
✓ Branch 0 taken 13243 times.
✗ Branch 1 not taken.
13243 if(!p_igetw(&(temp_sub->x),f))
11386 return qe_invalid;
11387
11388
1/2
✓ Branch 0 taken 13243 times.
✗ Branch 1 not taken.
13243 if(!p_igetw(&(temp_sub->y),f))
11389 return qe_invalid;
11390
11391
1/2
✓ Branch 0 taken 13243 times.
✗ Branch 1 not taken.
13243 if(!p_igetw(&(temp_sub->w),f))
11392 return qe_invalid;
11393
11394
1/2
✓ Branch 0 taken 13243 times.
✗ Branch 1 not taken.
13243 if(!p_igetw(&(temp_sub->h),f))
11395 return qe_invalid;
11396
11397
1/2
✓ Branch 0 taken 13243 times.
✗ Branch 1 not taken.
13243 if(!p_getc(&(temp_sub->colortype1),f))
11398 return qe_invalid;
11399
11400
1/2
✓ Branch 0 taken 13243 times.
✗ Branch 1 not taken.
13243 if(!p_igetw(&(temp_sub->color1),f))
11401 return qe_invalid;
11402
11403
1/2
✓ Branch 0 taken 13243 times.
✗ Branch 1 not taken.
13243 if(!p_getc(&(temp_sub->colortype2),f))
11404 return qe_invalid;
11405
11406
1/2
✓ Branch 0 taken 13243 times.
✗ Branch 1 not taken.
13243 if(!p_igetw(&(temp_sub->color2),f))
11407 return qe_invalid;
11408
11409
1/2
✓ Branch 0 taken 13243 times.
✗ Branch 1 not taken.
13243 if(!p_getc(&(temp_sub->colortype3),f))
11410 return qe_invalid;
11411
11412
1/2
✓ Branch 0 taken 13243 times.
✗ Branch 1 not taken.
13243 if(!p_igetw(&(temp_sub->color3),f))
11413 return qe_invalid;
11414
11415
1/2
✓ Branch 0 taken 13243 times.
✗ Branch 1 not taken.
13243 if(!p_igetd(&(temp_sub->d1),f))
11416 return qe_invalid;
11417
11418
1/2
✓ Branch 0 taken 13243 times.
✗ Branch 1 not taken.
13243 if(!p_igetd(&(temp_sub->d2),f))
11419 return qe_invalid;
11420
11421
1/2
✓ Branch 0 taken 13243 times.
✗ Branch 1 not taken.
13243 if(!p_igetd(&(temp_sub->d3),f))
11422 return qe_invalid;
11423
11424
1/2
✓ Branch 0 taken 13243 times.
✗ Branch 1 not taken.
13243 if(!p_igetd(&(temp_sub->d4),f))
11425 return qe_invalid;
11426
11427
1/2
✓ Branch 0 taken 13243 times.
✗ Branch 1 not taken.
13243 if(!p_igetd(&(temp_sub->d5),f))
11428 return qe_invalid;
11429
11430
1/2
✓ Branch 0 taken 13243 times.
✗ Branch 1 not taken.
13243 if(!p_igetd(&(temp_sub->d6),f))
11431 return qe_invalid;
11432
11433
1/2
✓ Branch 0 taken 13243 times.
✗ Branch 1 not taken.
13243 if(!p_igetd(&(temp_sub->d7),f))
11434 return qe_invalid;
11435
11436
1/2
✓ Branch 0 taken 13243 times.
✗ Branch 1 not taken.
13243 if(!p_igetd(&(temp_sub->d8),f))
11437 return qe_invalid;
11438
11439
1/2
✓ Branch 0 taken 13243 times.
✗ Branch 1 not taken.
13243 if(!p_igetd(&(temp_sub->d9),f))
11440 return qe_invalid;
11441
11442
1/2
✓ Branch 0 taken 13243 times.
✗ Branch 1 not taken.
13243 if(!p_igetd(&(temp_sub->d10),f))
11443 return qe_invalid;
11444
11445
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13243 times.
13243 if(s_version < 2)
11446 {
11447 if(!p_igetl(&(temp_sub->speed),f))
11448 return qe_invalid;
11449
11450 if(!p_igetl(&(temp_sub->delay),f))
11451 return qe_invalid;
11452
11453 if(!p_igetl(&(temp_sub->frame),f))
11454 return qe_invalid;
11455 }
11456 else
11457 {
11458
1/2
✓ Branch 0 taken 13243 times.
✗ Branch 1 not taken.
13243 if(!p_getc(&(temp_sub->speed),f))
11459 return qe_invalid;
11460
11461
1/2
✓ Branch 0 taken 13243 times.
✗ Branch 1 not taken.
13243 if(!p_getc(&(temp_sub->delay),f))
11462 return qe_invalid;
11463
11464
1/2
✓ Branch 0 taken 13243 times.
✗ Branch 1 not taken.
13243 if(!p_igetw(&(temp_sub->frame),f))
11465 return qe_invalid;
11466 }
11467
11468 13243 int32_t temp_size=0;
11469
11470 // bool deletets = false;
11471
4/4
✓ Branch 0 taken 5853 times.
✓ Branch 1 taken 1329 times.
✓ Branch 2 taken 5910 times.
✓ Branch 3 taken 151 times.
13243 switch(temp_sub->type)
11472 {
11473 case ssoTEXT:
11474 case ssoTEXTBOX:
11475 case ssoCURRENTITEMTEXT:
11476 case ssoCURRENTITEMCLASSTEXT:
11477 {
11478 word temptempsize;
11479
11480
1/2
✓ Branch 0 taken 1329 times.
✗ Branch 1 not taken.
1329 if(!p_igetw(&temptempsize,f))
11481 {
11482 return qe_invalid;
11483 }
11484
11485 //temptempsize = temp1 + (temp2 << 8);
11486 1329 temp_size = (int32_t)temptempsize;
11487 1329 uint32_t char_length = temp_size+2;
11488
1/2
✓ Branch 0 taken 1329 times.
✗ Branch 1 not taken.
1329 if (char_length > MAX_DP1_LEN)
11489 {
11490 return qe_invalid;
11491 }
11492 1329 tempdp1[char_length - 1] = '\0';
11493
11494
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1329 times.
1329 if(temp_size)
11495
1/2
✓ Branch 0 taken 1329 times.
✗ Branch 1 not taken.
1329 if(!pfread(tempdp1,temp_size+1,f))
11496 return qe_invalid;
11497 1329 break;
11498 }
11499
11500 case ssoLIFEMETER:
11501
1/2
✓ Branch 0 taken 151 times.
✗ Branch 1 not taken.
151 if(get_bit(deprecated_rules, 12) != 0) // qr_24HC
11502 temp_sub->d3 = 1;
11503
11504
1/2
✓ Branch 0 taken 151 times.
✗ Branch 1 not taken.
151 if(!p_getc(&(temp_sub->dp1),f))
11505 return qe_invalid;
11506
11507 151 break;
11508
11509
11510 case ssoCURRENTITEM:
11511
11512
1/2
✓ Branch 0 taken 5853 times.
✗ Branch 1 not taken.
5853 if(s_version < 6)
11513 {
11514 switch(temp_sub->d1)
11515 {
11516 case ssiBOMB:
11517 temp_sub->d1 = itype_bomb;
11518 break;
11519
11520 case ssiSWORD:
11521 temp_sub->d1 = itype_sword;
11522 break;
11523
11524 case ssiSHIELD:
11525 temp_sub->d1 = itype_shield;
11526 break;
11527
11528 case ssiCANDLE:
11529 temp_sub->d1 = itype_candle;
11530 break;
11531
11532 case ssiLETTER:
11533 temp_sub->d1 = itype_letter;
11534 break;
11535
11536 case ssiPOTION:
11537 temp_sub->d1 = itype_potion;
11538 break;
11539
11540 case ssiLETTERPOTION:
11541 temp_sub->d1 = itype_letterpotion;
11542 break;
11543
11544 case ssiBOW:
11545 temp_sub->d1 = itype_bow;
11546 break;
11547
11548 case ssiARROW:
11549 temp_sub->d1 = itype_arrow;
11550 break;
11551
11552 case ssiBOWANDARROW:
11553 temp_sub->d1 = itype_bowandarrow;
11554 break;
11555
11556 case ssiBAIT:
11557 temp_sub->d1 = itype_bait;
11558 break;
11559
11560 case ssiRING:
11561 temp_sub->d1 = itype_ring;
11562 break;
11563
11564 case ssiBRACELET:
11565 temp_sub->d1 = itype_bracelet;
11566 break;
11567
11568 case ssiMAP:
11569 temp_sub->d1 = itype_map;
11570 break;
11571
11572 case ssiCOMPASS:
11573 temp_sub->d1 = itype_compass;
11574 break;
11575
11576 case ssiBOSSKEY:
11577 temp_sub->d1 = itype_bosskey;
11578 break;
11579
11580 case ssiMAGICKEY:
11581 temp_sub->d1 = itype_magickey;
11582 break;
11583
11584 case ssiBRANG:
11585 temp_sub->d1 = itype_brang;
11586 break;
11587
11588 case ssiWAND:
11589 temp_sub->d1 = itype_wand;
11590 break;
11591
11592 case ssiRAFT:
11593 temp_sub->d1 = itype_raft;
11594 break;
11595
11596 case ssiLADDER:
11597 temp_sub->d1 = itype_ladder;
11598 break;
11599
11600 case ssiWHISTLE:
11601 temp_sub->d1 = itype_whistle;
11602 break;
11603
11604 case ssiBOOK:
11605 temp_sub->d1 = itype_book;
11606 break;
11607
11608 case ssiWALLET:
11609 temp_sub->d1 = itype_wallet;
11610 break;
11611
11612 case ssiSBOMB:
11613 temp_sub->d1 = itype_sbomb;
11614 break;
11615
11616 case ssiHCPIECE:
11617 temp_sub->d1 = itype_heartpiece;
11618 break;
11619
11620 case ssiAMULET:
11621 temp_sub->d1 = itype_amulet;
11622 break;
11623
11624 case ssiFLIPPERS:
11625 temp_sub->d1 = itype_flippers;
11626 break;
11627
11628 case ssiHOOKSHOT:
11629 temp_sub->d1 = itype_hookshot;
11630 break;
11631
11632 case ssiLENS:
11633 temp_sub->d1 = itype_lens;
11634 break;
11635
11636 case ssiHAMMER:
11637 temp_sub->d1 = itype_hammer;
11638 break;
11639
11640 case ssiBOOTS:
11641 temp_sub->d1 = itype_boots;
11642 break;
11643
11644 case ssiDIVINEFIRE:
11645 temp_sub->d1 = itype_divinefire;
11646 break;
11647
11648 case ssiDIVINEESCAPE:
11649 temp_sub->d1 = itype_divineescape;
11650 break;
11651
11652 case ssiDIVINEPROTECTION:
11653 temp_sub->d1 = itype_divineprotection;
11654 break;
11655
11656 case ssiQUIVER:
11657 temp_sub->d1 = itype_quiver;
11658 break;
11659
11660 case ssiBOMBBAG:
11661 temp_sub->d1 = itype_bombbag;
11662 break;
11663
11664 case ssiCBYRNA:
11665 temp_sub->d1 = itype_cbyrna;
11666 break;
11667
11668 case ssiROCS:
11669 temp_sub->d1 = itype_rocs;
11670 break;
11671
11672 case ssiHOVERBOOTS:
11673 temp_sub->d1 = itype_hoverboots;
11674 break;
11675
11676 case ssiSPINSCROLL:
11677 temp_sub->d1 = itype_spinscroll;
11678 break;
11679
11680 case ssiCROSSSCROLL:
11681 temp_sub->d1 = itype_crossscroll;
11682 break;
11683
11684 case ssiQUAKESCROLL:
11685 temp_sub->d1 = itype_quakescroll;
11686 break;
11687
11688 case ssiWHISPRING:
11689 temp_sub->d1 = itype_whispring;
11690 break;
11691
11692 case ssiCHARGERING:
11693 temp_sub->d1 = itype_chargering;
11694 break;
11695
11696 case ssiPERILSCROLL:
11697 temp_sub->d1 = itype_perilscroll;
11698 break;
11699
11700 case ssiWEALTHMEDAL:
11701 temp_sub->d1 = itype_wealthmedal;
11702 break;
11703
11704 case ssiHEARTRING:
11705 temp_sub->d1 = itype_heartring;
11706 break;
11707
11708 case ssiMAGICRING:
11709 temp_sub->d1 = itype_magicring;
11710 break;
11711
11712 case ssiSPINSCROLL2:
11713 temp_sub->d1 = itype_spinscroll2;
11714 break;
11715
11716 case ssiQUAKESCROLL2:
11717 temp_sub->d1 = itype_quakescroll2;
11718 break;
11719
11720 case ssiAGONY:
11721 temp_sub->d1 = itype_agony;
11722 break;
11723
11724 case ssiSTOMPBOOTS:
11725 temp_sub->d1 = itype_stompboots;
11726 break;
11727
11728 case ssiWHIMSICALRING:
11729 temp_sub->d1 = itype_whimsicalring;
11730 break;
11731
11732 case ssiPERILRING:
11733 temp_sub->d1 = itype_perilring;
11734 break;
11735
11736 default:
11737 temp_sub->d1 += itype_custom1 - ssiMAX;
11738 }
11739 }
11740
11741 //fall-through
11742 default:
11743
1/2
✓ Branch 0 taken 11763 times.
✗ Branch 1 not taken.
11763 if(!p_getc(&(temp_sub->dp1),f))
11744 return qe_invalid;
11745
11746 11763 break;
11747 }
11748
11749
2/2
✓ Branch 0 taken 4559 times.
✓ Branch 1 taken 8684 times.
13243 if(s_version < 7)
11750 {
11751
3/3
✓ Branch 0 taken 8025 times.
✓ Branch 1 taken 227 times.
✓ Branch 2 taken 432 times.
8684 switch(temp_sub->type)
11752 {
11753 case ssoMAGICGAUGE:
11754 {
11755
2/2
✓ Branch 0 taken 35 times.
✓ Branch 1 taken 192 times.
227 if(!temp_sub->d9)
11756 192 temp_sub->d9 = -1; //-1 now represents 'always'
11757 227 break;
11758 }
11759 case ssoLIFEGAUGE:
11760 432 temp_sub->d9 = 0; //Unused, doesn't do anything? Clear it...
11761 432 break;
11762 }
11763 8684 }
11764
11765
3/3
✓ Branch 0 taken 1329 times.
✓ Branch 1 taken 11457 times.
✓ Branch 2 taken 457 times.
13243 switch(temp_sub->type)
11766 {
11767 case ssoTEXT:
11768 case ssoTEXTBOX:
11769 case ssoCURRENTITEMTEXT:
11770 case ssoCURRENTITEMCLASSTEXT:
11771
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1329 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1329 if(g->objects[j].dp1 != NULL) delete[](char *)g->objects[j].dp1;
11772
11773 1329 memcpy(&g->objects[j],temp_sub,sizeof(subscreen_object));
11774 1329 g->objects[j].dp1 = new char[temp_size+2];
11775 1329 strcpy((char*)g->objects[j].dp1,tempdp1);
11776 1329 break;
11777
11778 case ssoCOUNTER:
11779
1/2
✓ Branch 0 taken 457 times.
✗ Branch 1 not taken.
457 if(s_version<3)
11780 {
11781 temp_sub->d6=(temp_sub->d6?1:0)+(temp_sub->d8?2:0);
11782 temp_sub->d8=0;
11783 }
11784
11785 default:
11786 11914 memcpy(&g->objects[j],temp_sub,sizeof(subscreen_object));
11787 11914 break;
11788 }
11789
11790 13243 g->name[0] = '\0';
11791 13243 strncat(g->name, tempname, 64 - 1);
11792 13243 g->ss_type = temp_ss;
11793 13243 }
11794
11795
2/2
✓ Branch 0 taken 2804805 times.
✓ Branch 1 taken 11008 times.
2815813 for(j=numsub; j<MAXSUBSCREENITEMS; j++)
11796 {
11797 //clear all unused object in this subscreen -DD
11798
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2804805 times.
2804805 switch(g->objects[j].type)
11799 {
11800 case ssoTEXT:
11801 case ssoTEXTBOX:
11802 case ssoCURRENTITEMTEXT:
11803 case ssoCURRENTITEMCLASSTEXT:
11804 if(g->objects[j].dp1 != NULL) delete [](char *)g->objects[j].dp1;
11805
11806 //fall through
11807 default:
11808 2804805 memset(&g->objects[j],0,sizeof(subscreen_object));
11809 2804805 break;
11810 }
11811 2804805 }
11812
11813 11008 return 0;
11814 11008 }
11815
11816 112 int32_t readsubscreens(PACKFILE *f)
11817 {
11818 word s_version, s_cversion;
11819 dword dummy;
11820
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 112 times.
112 if(!p_igetw(&s_version,f))
11821 return qe_invalid;
11822 112 FFCore.quest_format[vSubscreen] = s_version;
11823
1/2
✓ Branch 0 taken 112 times.
✗ Branch 1 not taken.
112 if(!p_igetw(&s_cversion,f))
11824 return qe_invalid;
11825
1/2
✓ Branch 0 taken 112 times.
✗ Branch 1 not taken.
112 if(!p_igetl(&dummy,f)) //section size
11826 return qe_invalid;
11827
11828
2/2
✓ Branch 0 taken 86 times.
✓ Branch 1 taken 26 times.
112 if(s_version < 8)
11829 86 return read_old_subscreens(f,s_version);
11830
11831 26 subscreens_active.clear();
11832 26 subscreens_passive.clear();
11833 26 subscreens_overlay.clear();
11834
11835 byte sz;
11836
1/2
✓ Branch 0 taken 26 times.
✗ Branch 1 not taken.
26 if(!p_getc(&sz,f))
11837 return qe_invalid;
11838
2/2
✓ Branch 0 taken 80 times.
✓ Branch 1 taken 26 times.
106 for(byte q = 0; q < sz; ++q)
11839 {
11840 80 ZCSubscreen& tmp = subscreens_active.emplace_back();
11841
1/2
✓ Branch 0 taken 80 times.
✗ Branch 1 not taken.
80 if (auto ret = tmp.read(f, s_version))
11842 return ret;
11843 80 }
11844
1/2
✓ Branch 0 taken 26 times.
✗ Branch 1 not taken.
26 if(!p_getc(&sz,f))
11845 return qe_invalid;
11846
2/2
✓ Branch 0 taken 104 times.
✓ Branch 1 taken 26 times.
130 for(byte q = 0; q < sz; ++q)
11847 {
11848 104 ZCSubscreen& tmp = subscreens_passive.emplace_back();
11849
1/2
✓ Branch 0 taken 104 times.
✗ Branch 1 not taken.
104 if (auto ret = tmp.read(f, s_version))
11850 return ret;
11851 104 }
11852
1/2
✓ Branch 0 taken 26 times.
✗ Branch 1 not taken.
26 if(!p_getc(&sz,f))
11853 return qe_invalid;
11854
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 26 times.
42 for(byte q = 0; q < sz; ++q)
11855 {
11856 16 ZCSubscreen& tmp = subscreens_overlay.emplace_back();
11857
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 if (auto ret = tmp.read(f, s_version))
11858 return ret;
11859 16 }
11860 26 return 0;
11861 112 }
11862
11863 void reset_subscreen(subscreen_group *tempss)
11864 {
11865 for(int32_t i=0; i<MAXSUBSCREENITEMS; ++i)
11866 {
11867 switch(tempss->objects[i].type)
11868 {
11869 case ssoTEXT:
11870 case ssoTEXTBOX:
11871 case ssoCURRENTITEMTEXT:
11872 case ssoCURRENTITEMCLASSTEXT:
11873 if(tempss->objects[i].dp1 != NULL) delete [](char *)tempss->objects[i].dp1;
11874
11875 //fall through
11876 default:
11877 memset(&tempss->objects[i],0,sizeof(subscreen_object));
11878 break;
11879 }
11880 }
11881 }
11882
11883 31 void reset_subscreens()
11884 {
11885 31 subscreens_active.clear();
11886 31 subscreens_passive.clear();
11887 31 subscreens_overlay.clear();
11888 31 }
11889
11890 31 int32_t setupsubscreens()
11891 {
11892 31 reset_subscreens();
11893 //return 0;
11894
2/2
✓ Branch 0 taken 31 times.
✓ Branch 1 taken 62 times.
93 for(int q = 0; q < 2; ++q)
11895 {
11896 62 subscreens_active.emplace_back();
11897 62 subscreens_passive.emplace_back();
11898 62 }
11899 31 int32_t tempsubscreen=subscr_mode;
11900
11901
1/2
✓ Branch 0 taken 31 times.
✗ Branch 1 not taken.
31 if(tempsubscreen>=ssdtMAX)
11902 tempsubscreen=0;
11903
11904
1/3
✗ Branch 0 not taken.
✓ Branch 1 taken 31 times.
✗ Branch 2 not taken.
31 switch(tempsubscreen)
11905 {
11906 case ssdtOLD:
11907 case ssdtNEWSUBSCR:
11908 case ssdtREV2:
11909 case ssdtBSZELDA:
11910 case ssdtBSZELDAMODIFIED:
11911 case ssdtBSZELDAENHANCED:
11912 case ssdtBSZELDACOMPLETE:
11913 {
11914 31 subscreens_active[0].load_old(default_subscreen_active[tempsubscreen][0]);
11915 31 subscreens_active[0].sub_type=sstACTIVE;
11916 31 subscreens_active[0].name = "Active Subscreen (Triforce)";
11917 31 subscreens_active[1].load_old(default_subscreen_active[tempsubscreen][1]);
11918 31 subscreens_active[1].sub_type=sstACTIVE;
11919 31 subscreens_active[1].name = "Active Subscreen (Dungeon Map)";
11920 31 subscreens_passive[0].load_old(default_subscreen_passive[tempsubscreen][0]);
11921 31 subscreens_passive[0].sub_type=sstPASSIVE;
11922 31 subscreens_passive[0].name = "Passive Subscreen (Magic)";
11923 31 subscreens_passive[1].load_old(default_subscreen_passive[tempsubscreen][1]);
11924 31 subscreens_passive[1].sub_type=sstPASSIVE;
11925 31 subscreens_passive[1].name = "Passive Subscreen (No Magic)";
11926 31 break;
11927 }
11928
11929 case ssdtZ3:
11930 {
11931 subscreens_active[0].load_old(z3_active_a);
11932 subscreens_active[0].sub_type=sstACTIVE;
11933 subscreens_active[1].load_old(z3_active_ab);
11934 subscreens_active[1].sub_type=sstACTIVE;
11935 subscreens_passive[0].load_old(z3_passive_a);
11936 subscreens_passive[0].sub_type=sstPASSIVE;
11937 subscreens_passive[1].load_old(z3_passive_ab);
11938 subscreens_passive[1].sub_type=sstPASSIVE;
11939 break;
11940 }
11941 }
11942 31 subscr_mode = ssdtMAX;
11943 31 return 0;
11944 }
11945
11946 extern script_data *ffscripts[NUMSCRIPTFFC];
11947 extern script_data *itemscripts[NUMSCRIPTITEM];
11948 extern script_data *guyscripts[NUMSCRIPTGUYS];
11949 extern script_data *lwpnscripts[NUMSCRIPTWEAPONS];
11950 extern script_data *ewpnscripts[NUMSCRIPTWEAPONS];
11951 extern script_data *globalscripts[NUMSCRIPTGLOBAL];
11952 extern script_data *genericscripts[NUMSCRIPTSGENERIC];
11953 extern script_data *playerscripts[NUMSCRIPTPLAYER];
11954 extern script_data *screenscripts[NUMSCRIPTSCREEN];
11955 extern script_data *dmapscripts[NUMSCRIPTSDMAP];
11956 extern script_data *itemspritescripts[NUMSCRIPTSITEMSPRITE];
11957 extern script_data *comboscripts[NUMSCRIPTSCOMBODATA];
11958 extern script_data *subscreenscripts[NUMSCRIPTSSUBSCREEN];
11959
11960
11961
11962 102 int32_t readffscript(PACKFILE *f, zquestheader *Header)
11963 {
11964 int32_t dummy;
11965 102 word s_version=0, s_cversion=0, zmeta_version=0;
11966 102 byte numscripts=0;
11967 102 numscripts=numscripts; //to avoid unused variables warnings
11968 int32_t ret;
11969
11970 //section version info
11971
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 102 times.
102 if(!p_igetw(&s_version,f))
11972 {
11973 return qe_invalid;
11974 }
11975
11976 102 FFCore.quest_format[vFFScript] = s_version;
11977
11978
1/2
✓ Branch 0 taken 102 times.
✗ Branch 1 not taken.
102 if(!p_igetw(&s_cversion,f))
11979 {
11980 return qe_invalid;
11981 }
11982
11983
2/2
✓ Branch 0 taken 67 times.
✓ Branch 1 taken 35 times.
102 if(s_version >= 18)
11984 {
11985
1/2
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
35 if(!p_igetw(&zmeta_version,f))
11986 {
11987 return qe_invalid;
11988 }
11989 35 }
11990
11991 //al_trace("Scripts version %d\n", s_version);
11992 //section size
11993
1/2
✓ Branch 0 taken 102 times.
✗ Branch 1 not taken.
102 if(!p_igetl(&dummy,f))
11994 {
11995 return qe_invalid;
11996 }
11997
11998 //ZScriptVersion::setVersion(s_version); ~this ideally, but there's no ZC/ZQuest defines...
11999 102 setZScriptVersion(s_version); //Lumped in zelda.cpp and in zquest.cpp as zquest can't link ZScriptVersion
12000 //miscQdata *the_misc;
12001
2/2
✓ Branch 0 taken 25 times.
✓ Branch 1 taken 77 times.
102 if ( FFCore.quest_format[vLastCompile] < 13 ) FFCore.quest_format[vLastCompile] = s_version;
12002 102 al_trace("Loaded scripts last compiled in ZScript version: %d\n", (FFCore.quest_format[vLastCompile]));
12003
12004 //finally... section data
12005
2/2
✓ Branch 0 taken 57344 times.
✓ Branch 1 taken 62 times.
57446 for(int32_t i = 0; i < ((s_version < 2) ? NUMSCRIPTFFCOLD : NUMSCRIPTFFC); i++)
12006 {
12007 57344 ret = read_one_ffscript(f, Header, i, s_version, s_cversion, &ffscripts[i], zmeta_version);
12008
12009
1/2
✓ Branch 0 taken 57344 times.
✗ Branch 1 not taken.
57344 if (ret)
12010 {
12011 return qe_invalid;
12012 }
12013 57344 }
12014
12015 /* HIGHLY UNORTHODOX UPDATING THING, by Deedee
12016 * This fixes changes to sprite jump values introduced in early 2.55 alphas.
12017 * Zoria didn't bump up the versions as liberally as he should have, but thankfully
12018 * there was a version bump a week before a change that broke stuff.
12019 */
12020
7/8
✓ Branch 0 taken 35 times.
✓ Branch 1 taken 27 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 35 times.
✓ Branch 4 taken 35 times.
✓ Branch 5 taken 35 times.
✓ Branch 6 taken 35 times.
✓ Branch 7 taken 35 times.
62 if(((Header->zelda_version < 0x253)||((Header->zelda_version == 0x253)&&(Header->build<33))||((Header->zelda_version > 0x253) && s_version < 12)))
12021 {
12022 97 set_qr(qr_SPRITE_JUMP_IS_TRUNCATED,1);
12023 97 }
12024
2/2
✓ Branch 0 taken 35 times.
✓ Branch 1 taken 77 times.
112 if(s_version < 19)
12025 {
12026 77 set_qr(qr_FLUCTUATING_ENEMY_JUMP,1);
12027 77 }
12028
12029
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 112 times.
112 if(s_version > 1)
12030 {
12031
2/2
✓ Branch 0 taken 28672 times.
✓ Branch 1 taken 112 times.
28784 for(int32_t i = 0; i < NUMSCRIPTITEM; i++)
12032 {
12033 28672 ret = read_one_ffscript(f, Header, i, s_version, s_cversion, &itemscripts[i], zmeta_version);
12034
12035
1/2
✓ Branch 0 taken 28672 times.
✗ Branch 1 not taken.
28672 if (ret)
12036 {
12037 return qe_invalid;
12038 }
12039 28672 }
12040
12041
2/2
✓ Branch 0 taken 28672 times.
✓ Branch 1 taken 112 times.
28784 for(int32_t i = 0; i < NUMSCRIPTGUYS; i++)
12042 {
12043 28672 ret = read_one_ffscript(f, Header, i, s_version, s_cversion, &guyscripts[i], zmeta_version);
12044
12045
1/2
✓ Branch 0 taken 28672 times.
✗ Branch 1 not taken.
28672 if (ret)
12046 {
12047 return qe_invalid;
12048 }
12049 28672 }
12050
12051
1/2
✓ Branch 0 taken 112 times.
✗ Branch 1 not taken.
112 script_data *fake = new script_data(ScriptType::None, 0);
12052
2/2
✓ Branch 0 taken 28672 times.
✓ Branch 1 taken 112 times.
28784 for(int32_t i = 0; i < NUMSCRIPTWEAPONS; i++)
12053 {
12054 28672 ret = read_one_ffscript(f, Header, i, s_version, s_cversion, &fake, zmeta_version);
12055
12056
1/2
✓ Branch 0 taken 28672 times.
✗ Branch 1 not taken.
28672 if (ret)
12057 {
12058 return qe_invalid;
12059 }
12060 28672 }
12061
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 112 times.
112 delete fake;
12062
12063
2/2
✓ Branch 0 taken 28672 times.
✓ Branch 1 taken 112 times.
28784 for(int32_t i = 0; i < NUMSCRIPTSCREEN; i++)
12064 {
12065 28672 ret = read_one_ffscript(f, Header, i, s_version, s_cversion, &screenscripts[i], zmeta_version);
12066
12067
1/2
✓ Branch 0 taken 28672 times.
✗ Branch 1 not taken.
28672 if (ret)
12068 {
12069 return qe_invalid;
12070 }
12071 28672 }
12072
12073
2/2
✓ Branch 0 taken 35 times.
✓ Branch 1 taken 77 times.
112 if(s_version > 16)
12074 {
12075
2/2
✓ Branch 0 taken 280 times.
✓ Branch 1 taken 35 times.
315 for(int32_t i = 0; i < NUMSCRIPTGLOBAL; ++i)
12076 {
12077 280 ret = read_one_ffscript(f, Header, i, s_version, s_cversion, &globalscripts[i], zmeta_version);
12078
12079
1/2
✓ Branch 0 taken 280 times.
✗ Branch 1 not taken.
280 if (ret)
12080 {
12081 return qe_invalid;
12082 }
12083 280 }
12084 35 }
12085
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 77 times.
77 else if(s_version > 13)
12086 {
12087 for(int32_t i = 0; i < NUMSCRIPTGLOBAL255OLD; ++i)
12088 {
12089 ret = read_one_ffscript(f, Header, i, s_version, s_cversion, &globalscripts[i], zmeta_version);
12090
12091 if (ret)
12092 {
12093 return qe_invalid;
12094 }
12095 }
12096
12097 if(globalscripts[GLOBAL_SCRIPT_ONSAVE] != NULL)
12098 delete globalscripts[GLOBAL_SCRIPT_ONSAVE];
12099
12100 globalscripts[GLOBAL_SCRIPT_ONSAVE] = new script_data(ScriptType::Global, GLOBAL_SCRIPT_ONSAVE);
12101 }
12102
1/2
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
77 else if(s_version > 4)
12103 {
12104
2/2
✓ Branch 0 taken 308 times.
✓ Branch 1 taken 77 times.
385 for(int32_t i = 0; i < NUMSCRIPTGLOBAL253; ++i)
12105 {
12106 308 ret = read_one_ffscript(f, Header, i, s_version, s_cversion, &globalscripts[i], zmeta_version);
12107
12108
1/2
✓ Branch 0 taken 308 times.
✗ Branch 1 not taken.
308 if (ret)
12109 {
12110 return qe_invalid;
12111 }
12112 308 }
12113
12114
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 77 times.
77 if(globalscripts[GLOBAL_SCRIPT_ONLAUNCH] != NULL)
12115
1/2
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
77 delete globalscripts[GLOBAL_SCRIPT_ONLAUNCH];
12116
12117
1/2
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
77 globalscripts[GLOBAL_SCRIPT_ONLAUNCH] = new script_data(ScriptType::Global, GLOBAL_SCRIPT_ONLAUNCH);
12118
12119
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 77 times.
77 if(globalscripts[GLOBAL_SCRIPT_ONCONTGAME] != NULL)
12120
1/2
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
77 delete globalscripts[GLOBAL_SCRIPT_ONCONTGAME];
12121
12122
1/2
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
77 globalscripts[GLOBAL_SCRIPT_ONCONTGAME] = new script_data(ScriptType::Global, GLOBAL_SCRIPT_ONCONTGAME);
12123
12124
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 77 times.
77 if(globalscripts[GLOBAL_SCRIPT_F6] != NULL)
12125
1/2
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
77 delete globalscripts[GLOBAL_SCRIPT_F6];
12126
12127
1/2
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
77 globalscripts[GLOBAL_SCRIPT_F6] = new script_data(ScriptType::Global, GLOBAL_SCRIPT_F6);
12128
12129
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 77 times.
77 if(globalscripts[GLOBAL_SCRIPT_ONSAVE] != NULL)
12130
1/2
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
77 delete globalscripts[GLOBAL_SCRIPT_ONSAVE];
12131
12132
1/2
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
77 globalscripts[GLOBAL_SCRIPT_ONSAVE] = new script_data(ScriptType::Global, GLOBAL_SCRIPT_ONSAVE);
12133 77 }
12134 else
12135 {
12136 for(int32_t i = 0; i < NUMSCRIPTGLOBALOLD; i++)
12137 {
12138 ret = read_one_ffscript(f, Header, i, s_version, s_cversion, &globalscripts[i], zmeta_version);
12139
12140 if (ret)
12141 {
12142 return qe_invalid;
12143 }
12144 }
12145
12146 if(globalscripts[GLOBAL_SCRIPT_ONSAVELOAD] != NULL)
12147 delete globalscripts[GLOBAL_SCRIPT_ONSAVELOAD];
12148
12149 globalscripts[GLOBAL_SCRIPT_ONSAVELOAD] = new script_data(ScriptType::Global, GLOBAL_SCRIPT_ONSAVELOAD);
12150
12151 if(globalscripts[GLOBAL_SCRIPT_ONLAUNCH] != NULL)
12152 delete globalscripts[GLOBAL_SCRIPT_ONLAUNCH];
12153
12154 globalscripts[GLOBAL_SCRIPT_ONLAUNCH] = new script_data(ScriptType::Global, GLOBAL_SCRIPT_ONLAUNCH);
12155
12156 if(globalscripts[GLOBAL_SCRIPT_ONCONTGAME] != NULL)
12157 delete globalscripts[GLOBAL_SCRIPT_ONCONTGAME];
12158
12159 globalscripts[GLOBAL_SCRIPT_ONCONTGAME] = new script_data(ScriptType::Global, GLOBAL_SCRIPT_ONCONTGAME);
12160
12161 if(globalscripts[GLOBAL_SCRIPT_F6] != NULL)
12162 delete globalscripts[GLOBAL_SCRIPT_F6];
12163
12164 globalscripts[GLOBAL_SCRIPT_F6] = new script_data(ScriptType::Global, GLOBAL_SCRIPT_F6);
12165
12166 if(globalscripts[GLOBAL_SCRIPT_ONSAVE] != NULL)
12167 delete globalscripts[GLOBAL_SCRIPT_ONSAVE];
12168
12169 globalscripts[GLOBAL_SCRIPT_ONSAVE] = new script_data(ScriptType::Global, GLOBAL_SCRIPT_ONSAVE);
12170 }
12171
12172
2/2
✓ Branch 0 taken 35 times.
✓ Branch 1 taken 77 times.
112 if(s_version > 10) //expanded the number of Player scripts to 5.
12173 {
12174
2/2
✓ Branch 0 taken 175 times.
✓ Branch 1 taken 35 times.
210 for(int32_t i = 0; i < NUMSCRIPTPLAYER; i++)
12175 {
12176 175 ret = read_one_ffscript(f, Header, i, s_version, s_cversion, &playerscripts[i], zmeta_version);
12177
12178
1/2
✓ Branch 0 taken 175 times.
✗ Branch 1 not taken.
175 if (ret)
12179 {
12180 return qe_invalid;
12181 }
12182 175 }
12183 35 }
12184 else
12185 {
12186
2/2
✓ Branch 0 taken 231 times.
✓ Branch 1 taken 77 times.
308 for(int32_t i = 0; i < NUMSCRIPTHEROOLD; i++)
12187 {
12188 231 ret = read_one_ffscript(f, Header, i, s_version, s_cversion, &playerscripts[i], zmeta_version);
12189
12190
1/2
✓ Branch 0 taken 231 times.
✗ Branch 1 not taken.
231 if (ret)
12191 {
12192 return qe_invalid;
12193 }
12194 231 }
12195
1/2
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
77 if(playerscripts[3] != NULL)
12196
1/2
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
77 delete playerscripts[3];
12197
12198
1/2
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
77 playerscripts[3] = new script_data(ScriptType::Player, 3);
12199
12200
1/2
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
77 if(playerscripts[4] != NULL)
12201
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 77 times.
77 delete playerscripts[4];
12202
12203
1/2
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
77 playerscripts[4] = new script_data(ScriptType::Player, 4);
12204 }
12205
3/4
✓ Branch 0 taken 35 times.
✓ Branch 1 taken 77 times.
✓ Branch 2 taken 35 times.
✗ Branch 3 not taken.
112 if(s_version > 8 && s_version < 10)
12206 {
12207
12208 for(int32_t i = 0; i < NUMSCRIPTWEAPONS; i++)
12209 {
12210 ret = read_one_ffscript(f, Header, i, s_version, s_cversion, &ewpnscripts[i], zmeta_version);
12211
12212 if (ret)
12213 {
12214 return qe_invalid;
12215 }
12216 }
12217 for(int32_t i = 0; i < NUMSCRIPTSDMAP; i++)
12218 {
12219 ret = read_one_ffscript(f, Header, i, s_version, s_cversion, &dmapscripts[i], zmeta_version);
12220
12221 if (ret)
12222 {
12223 return qe_invalid;
12224 }
12225 }
12226
12227 }
12228
2/2
✓ Branch 0 taken 77 times.
✓ Branch 1 taken 35 times.
112 if(s_version >= 10)
12229 {
12230
2/2
✓ Branch 0 taken 8960 times.
✓ Branch 1 taken 35 times.
8995 for(int32_t i = 0; i < NUMSCRIPTWEAPONS; i++)
12231 {
12232 8960 ret = read_one_ffscript(f, Header, i, s_version, s_cversion, &lwpnscripts[i], zmeta_version);
12233
12234
1/2
✓ Branch 0 taken 8960 times.
✗ Branch 1 not taken.
8960 if (ret)
12235 {
12236 return qe_invalid;
12237 }
12238 8960 }
12239
2/2
✓ Branch 0 taken 8960 times.
✓ Branch 1 taken 35 times.
8995 for(int32_t i = 0; i < NUMSCRIPTWEAPONS; i++)
12240 {
12241 8960 ret = read_one_ffscript(f, Header, i, s_version, s_cversion, &ewpnscripts[i], zmeta_version);
12242
12243
1/2
✓ Branch 0 taken 8960 times.
✗ Branch 1 not taken.
8960 if (ret)
12244 {
12245 return qe_invalid;
12246 }
12247 8960 }
12248
2/2
✓ Branch 0 taken 8960 times.
✓ Branch 1 taken 35 times.
8995 for(int32_t i = 0; i < NUMSCRIPTSDMAP; i++)
12249 {
12250 8960 ret = read_one_ffscript(f, Header, i, s_version, s_cversion, &dmapscripts[i], zmeta_version);
12251
12252
1/2
✓ Branch 0 taken 8960 times.
✗ Branch 1 not taken.
8960 if (ret)
12253 {
12254 return qe_invalid;
12255 }
12256 8960 }
12257
12258 35 }
12259
2/2
✓ Branch 0 taken 77 times.
✓ Branch 1 taken 35 times.
112 if(s_version >=12)
12260 {
12261
2/2
✓ Branch 0 taken 8960 times.
✓ Branch 1 taken 35 times.
8995 for(int32_t i = 0; i < NUMSCRIPTSITEMSPRITE; i++)
12262 {
12263 8960 ret = read_one_ffscript(f, Header, i, s_version, s_cversion, &itemspritescripts[i], zmeta_version);
12264
12265
1/2
✓ Branch 0 taken 8960 times.
✗ Branch 1 not taken.
8960 if (ret)
12266 {
12267 return qe_invalid;
12268 }
12269 8960 }
12270 35 }
12271
2/2
✓ Branch 0 taken 77 times.
✓ Branch 1 taken 35 times.
112 if(s_version >=15)
12272 {
12273
2/2
✓ Branch 0 taken 17920 times.
✓ Branch 1 taken 35 times.
17955 for(int32_t i = 0; i < NUMSCRIPTSCOMBODATA; i++)
12274 {
12275 17920 ret = read_one_ffscript(f, Header, i, s_version, s_cversion, &comboscripts[i], zmeta_version);
12276
12277
1/2
✓ Branch 0 taken 17920 times.
✗ Branch 1 not taken.
17920 if (ret)
12278 {
12279 return qe_invalid;
12280 }
12281 17920 }
12282 35 }
12283
2/2
✓ Branch 0 taken 77 times.
✓ Branch 1 taken 35 times.
112 if(s_version >19)
12284 {
12285 35 word numgenscripts = NUMSCRIPTSGENERIC;
12286
1/2
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
35 if(!p_igetw(&numgenscripts,f))
12287 {
12288 return qe_invalid;
12289 }
12290
2/2
✓ Branch 0 taken 17920 times.
✓ Branch 1 taken 35 times.
17955 for(int32_t i = 0; i < numgenscripts; i++)
12291 {
12292 17920 ret = read_one_ffscript(f, Header, i, s_version, s_cversion, &genericscripts[i], zmeta_version);
12293
12294
1/2
✓ Branch 0 taken 17920 times.
✗ Branch 1 not taken.
17920 if (ret)
12295 {
12296 return qe_invalid;
12297 }
12298 17920 }
12299 35 }
12300
2/2
✓ Branch 0 taken 104 times.
✓ Branch 1 taken 8 times.
112 if(s_version >21)
12301 {
12302 8 word numsubscripts = NUMSCRIPTSSUBSCREEN;
12303
1/2
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
8 if(!p_igetw(&numsubscripts,f))
12304 {
12305 return qe_invalid;
12306 }
12307
2/2
✓ Branch 0 taken 2048 times.
✓ Branch 1 taken 8 times.
2056 for(int32_t i = 0; i < numsubscripts; i++)
12308 {
12309 2048 ret = read_one_ffscript(f, Header, i, s_version, s_cversion, &subscreenscripts[i], zmeta_version);
12310
12311
1/2
✓ Branch 0 taken 2048 times.
✗ Branch 1 not taken.
2048 if (ret)
12312 {
12313 return qe_invalid;
12314 }
12315 2048 }
12316 8 }
12317 112 }
12318
12319
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 112 times.
112 if(s_version > 2)
12320 {
12321 int32_t bufsize;
12322 112 p_igetl(&bufsize, f);
12323
2/4
✓ Branch 0 taken 112 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 112 times.
112 if (bufsize < 0 || bufsize > 1024*1024*10)
12324 {
12325 // God help anyone storing more than 10MB of code in the script buffer.
12326 return qe_invalid;
12327 }
12328 112 char * buf = new char[bufsize+1];
12329 112 pfread(buf, bufsize, f);
12330 112 buf[bufsize]=0;
12331
12332
1/2
✓ Branch 0 taken 112 times.
✗ Branch 1 not taken.
112 zScript = string(buf);
12333
12334
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 112 times.
112 delete[] buf;
12335 word numffcbindings;
12336 112 p_igetw(&numffcbindings, f);
12337
12338
2/2
✓ Branch 0 taken 1570 times.
✓ Branch 1 taken 112 times.
1682 for(int32_t i=0; i<numffcbindings; i++)
12339 {
12340 word id;
12341 1570 p_igetw(&id, f);
12342 1570 p_igetl(&bufsize, f);
12343
2/4
✓ Branch 0 taken 1570 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1570 times.
1570 if (bufsize < 0 || bufsize > 1024)
12344 return qe_invalid;
12345 1570 buf = new char[bufsize+1];
12346 1570 pfread(buf, bufsize, f);
12347 1570 buf[bufsize]=0;
12348
12349 //fix for buggy older saved quests -DD
12350
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1570 times.
1570 if(id < NUMSCRIPTFFC-1)
12351 1570 ffcmap[id].scriptname = buf;
12352
12353
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1570 times.
1570 delete[] buf;
12354 1570 }
12355
12356 word numglobalbindings;
12357 112 p_igetw(&numglobalbindings, f);
12358
12359
2/2
✓ Branch 0 taken 435 times.
✓ Branch 1 taken 112 times.
547 for(int32_t i=0; i<numglobalbindings; i++)
12360 {
12361 word id;
12362 435 p_igetw(&id, f);
12363 435 p_igetl(&bufsize, f);
12364
2/4
✓ Branch 0 taken 435 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 435 times.
✗ Branch 3 not taken.
435 if (bufsize < 0 || bufsize > 1024)
12365 return qe_invalid;
12366 435 buf = new char[bufsize+1];
12367 435 pfread(buf, bufsize, f);
12368 435 buf[bufsize]=0;
12369
12370 // id in principle should be valid, since slot assignment cannot assign a global script to a bogus slot.
12371 // However, because of a corruption bug, some 2.50.x quests contain bogus entries in the global bindings table.
12372 // Ignore these. -DD
12373
3/4
✓ Branch 0 taken 435 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 159 times.
✓ Branch 3 taken 276 times.
435 if(id >= 0 && id < NUMSCRIPTGLOBAL)
12374 {
12375 //Disable old '~Continue's, they'd wreak havoc. Bit messy, apologies ~Joe
12376
1/2
✓ Branch 0 taken 276 times.
✗ Branch 1 not taken.
276 if(strcmp(buf,"~Continue") == 0)
12377 {
12378 globalmap[id].scriptname = "";
12379
12380 if(globalscripts[GLOBAL_SCRIPT_ONSAVELOAD] != NULL)
12381 globalscripts[GLOBAL_SCRIPT_ONSAVELOAD]->disable();
12382 }
12383 else
12384 {
12385 276 globalmap[id].scriptname = buf;
12386 }
12387 276 }
12388
12389
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 435 times.
435 delete[] buf;
12390 435 }
12391
12392
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 112 times.
112 if(s_version > 3)
12393 {
12394 word numitembindings;
12395 112 p_igetw(&numitembindings, f);
12396
12397
2/2
✓ Branch 0 taken 98 times.
✓ Branch 1 taken 112 times.
210 for(int32_t i=0; i<numitembindings; i++)
12398 {
12399 word id;
12400 98 p_igetw(&id, f);
12401 98 p_igetl(&bufsize, f);
12402
2/4
✓ Branch 0 taken 98 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 98 times.
98 if (bufsize < 0 || bufsize > 1024)
12403 return qe_invalid;
12404 98 buf = new char[bufsize+1];
12405 98 pfread(buf, bufsize, f);
12406 98 buf[bufsize]=0;
12407
12408 //fix this too
12409
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 98 times.
98 if(id <NUMSCRIPTITEM-1)
12410 98 itemmap[id].scriptname = buf;
12411
12412
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 98 times.
98 delete[] buf;
12413 98 }
12414 112 }
12415 //(v9+)
12416
2/2
✓ Branch 0 taken 77 times.
✓ Branch 1 taken 35 times.
112 if(s_version > 8)
12417 {
12418 //npc scripts
12419 word numnpcbindings;
12420 35 p_igetw(&numnpcbindings, f);
12421
12422
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 35 times.
47 for(int32_t i=0; i<numnpcbindings; i++)
12423 {
12424 word id;
12425 12 p_igetw(&id, f);
12426 12 p_igetl(&bufsize, f);
12427
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 if (bufsize < 0 || bufsize > 1024)
12428 return qe_invalid;
12429 12 buf = new char[bufsize+1];
12430 12 pfread(buf, bufsize, f);
12431 12 buf[bufsize]=0;
12432
12433 //fix this too
12434
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if(id <NUMSCRIPTGUYS-1)
12435 12 npcmap[id].scriptname = buf;
12436
12437
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 delete[] buf;
12438 12 }
12439 //lweapon
12440 word numlwpnbindings;
12441 35 p_igetw(&numlwpnbindings, f);
12442
12443
2/2
✓ Branch 0 taken 42 times.
✓ Branch 1 taken 35 times.
77 for(int32_t i=0; i<numlwpnbindings; i++)
12444 {
12445 word id;
12446 42 p_igetw(&id, f);
12447 42 p_igetl(&bufsize, f);
12448
2/4
✓ Branch 0 taken 42 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 42 times.
✗ Branch 3 not taken.
42 if (bufsize < 0 || bufsize > 1024)
12449 return qe_invalid;
12450 42 buf = new char[bufsize+1];
12451 42 pfread(buf, bufsize, f);
12452 42 buf[bufsize]=0;
12453
12454 //fix this too
12455
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 42 times.
42 if(id <NUMSCRIPTWEAPONS-1)
12456 42 lwpnmap[id].scriptname = buf;
12457
12458
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 42 times.
42 delete[] buf;
12459 42 }
12460 //eweapon
12461 word numewpnbindings;
12462 35 p_igetw(&numewpnbindings, f);
12463
12464
2/2
✓ Branch 0 taken 63 times.
✓ Branch 1 taken 35 times.
98 for(int32_t i=0; i<numewpnbindings; i++)
12465 {
12466 word id;
12467 63 p_igetw(&id, f);
12468 63 p_igetl(&bufsize, f);
12469
2/4
✓ Branch 0 taken 63 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 63 times.
✗ Branch 3 not taken.
63 if (bufsize < 0 || bufsize > 1024)
12470 return qe_invalid;
12471 63 buf = new char[bufsize+1];
12472 63 pfread(buf, bufsize, f);
12473 63 buf[bufsize]=0;
12474
12475 //fix this too
12476
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 63 times.
63 if(id <NUMSCRIPTWEAPONS-1)
12477 63 ewpnmap[id].scriptname = buf;
12478
12479
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 63 times.
63 delete[] buf;
12480 63 }
12481 //hero
12482 word numherobindings;
12483 35 p_igetw(&numherobindings, f);
12484
12485
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 35 times.
40 for(int32_t i=0; i<numherobindings; i++)
12486 {
12487 word id;
12488 5 p_igetw(&id, f);
12489 5 p_igetl(&bufsize, f);
12490
2/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 5 times.
5 if (bufsize < 0 || bufsize > 1024)
12491 return qe_invalid;
12492 5 buf = new char[bufsize+1];
12493 5 pfread(buf, bufsize, f);
12494 5 buf[bufsize]=0;
12495
12496 //fix this too
12497
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
5 if(id <NUMSCRIPTPLAYER-1)
12498 5 playermap[id].scriptname = buf;
12499
12500
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 delete[] buf;
12501 5 }
12502 //dmaps
12503 word numdmapbindings;
12504 35 p_igetw(&numdmapbindings, f);
12505
12506
2/2
✓ Branch 0 taken 32 times.
✓ Branch 1 taken 35 times.
67 for(int32_t i=0; i<numdmapbindings; i++)
12507 {
12508 word id;
12509 32 p_igetw(&id, f);
12510 32 p_igetl(&bufsize, f);
12511
2/4
✓ Branch 0 taken 32 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 32 times.
✗ Branch 3 not taken.
32 if (bufsize < 0 || bufsize > 1024)
12512 return qe_invalid;
12513 32 buf = new char[bufsize+1];
12514 32 pfread(buf, bufsize, f);
12515 32 buf[bufsize]=0;
12516
12517 //fix this too
12518
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 32 times.
32 if(id <NUMSCRIPTSDMAP-1)
12519 32 dmapmap[id].scriptname = buf;
12520
12521
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 32 times.
32 delete[] buf;
12522 32 }
12523 //screen
12524 word numscreenbindings;
12525 35 p_igetw(&numscreenbindings, f);
12526
12527
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 35 times.
71 for(int32_t i=0; i<numscreenbindings; i++)
12528 {
12529 word id;
12530 36 p_igetw(&id, f);
12531 36 p_igetl(&bufsize, f);
12532
2/4
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 36 times.
✗ Branch 3 not taken.
36 if (bufsize < 0 || bufsize > 1024)
12533 return qe_invalid;
12534 36 buf = new char[bufsize+1];
12535 36 pfread(buf, bufsize, f);
12536 36 buf[bufsize]=0;
12537
12538 //fix this too
12539
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 36 times.
36 if(id <NUMSCRIPTSDMAP-1)
12540 36 screenmap[id].scriptname = buf;
12541
12542
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 36 times.
36 delete[] buf;
12543 36 }
12544 35 }
12545
2/2
✓ Branch 0 taken 77 times.
✓ Branch 1 taken 35 times.
112 if(s_version > 11)
12546 {
12547 word numspritebindings;
12548 35 p_igetw(&numspritebindings, f);
12549
12550
2/2
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 35 times.
45 for(int32_t i=0; i<numspritebindings; i++)
12551 {
12552 word id;
12553 10 p_igetw(&id, f);
12554 10 p_igetl(&bufsize, f);
12555
2/4
✓ Branch 0 taken 10 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 10 times.
✗ Branch 3 not taken.
10 if (bufsize < 0 || bufsize > 1024)
12556 return qe_invalid;
12557 10 buf = new char[bufsize+1];
12558 10 pfread(buf, bufsize, f);
12559 10 buf[bufsize]=0;
12560
12561 //fix this too
12562
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10 times.
10 if(id <NUMSCRIPTSDMAP-1)
12563 10 itemspritemap[id].scriptname = buf;
12564
12565
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10 times.
10 delete[] buf;
12566 10 }
12567 35 }
12568
2/2
✓ Branch 0 taken 77 times.
✓ Branch 1 taken 35 times.
112 if(s_version >= 15)
12569 {
12570 word numcombobindings;
12571 35 p_igetw(&numcombobindings, f);
12572
12573
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 35 times.
58 for(int32_t i=0; i<numcombobindings; i++)
12574 {
12575 word id;
12576 23 p_igetw(&id, f);
12577 23 p_igetl(&bufsize, f);
12578
2/4
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 23 times.
23 if (bufsize < 0 || bufsize > 1024)
12579 return qe_invalid;
12580 23 buf = new char[bufsize+1];
12581 23 pfread(buf, bufsize, f);
12582 23 buf[bufsize]=0;
12583
12584 //fix this too
12585
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 23 times.
23 if(id <NUMSCRIPTSCOMBODATA-1)
12586 23 comboscriptmap[id].scriptname = buf;
12587
12588
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 23 times.
23 delete[] buf;
12589 23 }
12590 35 }
12591
2/2
✓ Branch 0 taken 77 times.
✓ Branch 1 taken 35 times.
112 if(s_version > 19)
12592 {
12593 word numgenericbindings;
12594 35 p_igetw(&numgenericbindings, f);
12595
12596
2/2
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 35 times.
48 for(int32_t i=0; i<numgenericbindings; i++)
12597 {
12598 word id;
12599 13 p_igetw(&id, f);
12600 13 p_igetl(&bufsize, f);
12601
2/4
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 13 times.
13 if (bufsize < 0 || bufsize > 1024)
12602 return qe_invalid;
12603 13 buf = new char[bufsize+1];
12604 13 pfread(buf, bufsize, f);
12605 13 buf[bufsize]=0;
12606
12607 //fix this too
12608
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13 times.
13 if(id <NUMSCRIPTSGENERIC-1)
12609 13 genericmap[id].scriptname = buf;
12610
12611
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13 times.
13 delete[] buf;
12612 13 }
12613 35 }
12614
2/2
✓ Branch 0 taken 104 times.
✓ Branch 1 taken 8 times.
112 if(s_version > 21)
12615 {
12616 word numsubscreenbindings;
12617 8 p_igetw(&numsubscreenbindings, f);
12618
12619
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8 times.
8 for(int32_t i=0; i<numsubscreenbindings; i++)
12620 {
12621 word id;
12622 p_igetw(&id, f);
12623 p_igetl(&bufsize, f);
12624 if (bufsize < 0 || bufsize > 1024)
12625 return qe_invalid;
12626 buf = new char[bufsize+1];
12627 pfread(buf, bufsize, f);
12628 buf[bufsize]=0;
12629
12630 //fix this too
12631 if(id <NUMSCRIPTSSUBSCREEN-1)
12632 subscreenmap[id].scriptname = buf;
12633
12634 delete[] buf;
12635 }
12636 8 }
12637 112 }
12638
12639 112 return 0;
12640 112 }
12641
12642 128 void reset_scripts()
12643 {
12644 #ifdef IS_PLAYER
12645 // We can't modify the script data while jit threads are possibly compiling them.
12646 void jit_shutdown();
12647 128 jit_shutdown();
12648 #endif
12649
12650
2/2
✓ Branch 0 taken 65536 times.
✓ Branch 1 taken 128 times.
65664 for(int32_t i=0; i<NUMSCRIPTSGENERIC; i++)
12651 {
12652
1/2
✓ Branch 0 taken 65536 times.
✗ Branch 1 not taken.
65536 if (genericscripts[i]!=NULL) genericscripts[i]->disable();
12653 else genericscripts[i] = new script_data({ScriptType::Generic, i});
12654 65536 }
12655
12656
2/2
✓ Branch 0 taken 65536 times.
✓ Branch 1 taken 128 times.
65664 for(int32_t i=0; i<NUMSCRIPTFFC; i++)
12657 {
12658
1/2
✓ Branch 0 taken 65536 times.
✗ Branch 1 not taken.
65536 if (ffscripts[i])
12659 65536 ffscripts[i]->disable();
12660 else
12661 ffscripts[i] = new script_data(ScriptType::FFC, i);
12662 65536 }
12663
12664
2/2
✓ Branch 0 taken 32768 times.
✓ Branch 1 taken 128 times.
32896 for(int32_t i=0; i<NUMSCRIPTITEM; i++)
12665 {
12666
1/2
✓ Branch 0 taken 32768 times.
✗ Branch 1 not taken.
32768 if (itemscripts[i])
12667 32768 itemscripts[i]->disable();
12668 else
12669 itemscripts[i] = new script_data(ScriptType::Item, i);
12670 32768 }
12671
12672
2/2
✓ Branch 0 taken 32768 times.
✓ Branch 1 taken 128 times.
32896 for(int32_t i=0; i<NUMSCRIPTGUYS; i++)
12673 {
12674
1/2
✓ Branch 0 taken 32768 times.
✗ Branch 1 not taken.
32768 if (guyscripts[i])
12675 32768 guyscripts[i]->disable();
12676 else
12677 guyscripts[i] = new script_data(ScriptType::NPC, i);
12678 32768 }
12679
12680
2/2
✓ Branch 0 taken 32768 times.
✓ Branch 1 taken 128 times.
32896 for(int32_t i=0; i<NUMSCRIPTSCREEN; i++)
12681 {
12682
1/2
✓ Branch 0 taken 32768 times.
✗ Branch 1 not taken.
32768 if (screenscripts[i])
12683 32768 screenscripts[i]->disable();
12684 else
12685 screenscripts[i] = new script_data(ScriptType::Screen, i);
12686 32768 }
12687
12688
2/2
✓ Branch 0 taken 1024 times.
✓ Branch 1 taken 128 times.
1152 for(int32_t i=0; i<NUMSCRIPTGLOBAL; i++)
12689 {
12690
1/2
✓ Branch 0 taken 1024 times.
✗ Branch 1 not taken.
1024 if (globalscripts[i])
12691 1024 globalscripts[i]->disable();
12692 else
12693 globalscripts[i] = new script_data(ScriptType::Global, i);
12694 1024 }
12695
12696
2/2
✓ Branch 0 taken 640 times.
✓ Branch 1 taken 128 times.
768 for(int32_t i=0; i<NUMSCRIPTPLAYER; i++)
12697 {
12698
1/2
✓ Branch 0 taken 640 times.
✗ Branch 1 not taken.
640 if (playerscripts[i])
12699 640 playerscripts[i]->disable();
12700 else
12701 playerscripts[i] = new script_data(ScriptType::Player, i);
12702 640 }
12703
12704
2/2
✓ Branch 0 taken 32768 times.
✓ Branch 1 taken 128 times.
32896 for(int32_t i=0; i<NUMSCRIPTWEAPONS; i++)
12705 {
12706
1/2
✓ Branch 0 taken 32768 times.
✗ Branch 1 not taken.
32768 if (lwpnscripts[i])
12707 32768 lwpnscripts[i]->disable();
12708 else
12709 lwpnscripts[i] = new script_data(ScriptType::Lwpn, i);
12710 32768 }
12711
2/2
✓ Branch 0 taken 32768 times.
✓ Branch 1 taken 128 times.
32896 for(int32_t i=0; i<NUMSCRIPTWEAPONS; i++)
12712 {
12713
1/2
✓ Branch 0 taken 32768 times.
✗ Branch 1 not taken.
32768 if (ewpnscripts[i])
12714 32768 ewpnscripts[i]->disable();
12715 else
12716 ewpnscripts[i] = new script_data(ScriptType::Ewpn, i);
12717 32768 }
12718
12719
2/2
✓ Branch 0 taken 32768 times.
✓ Branch 1 taken 128 times.
32896 for(int32_t i=0; i<NUMSCRIPTSDMAP; i++)
12720 {
12721
1/2
✓ Branch 0 taken 32768 times.
✗ Branch 1 not taken.
32768 if (dmapscripts[i])
12722 32768 dmapscripts[i]->disable();
12723 else
12724 dmapscripts[i] = new script_data(ScriptType::DMap, i);
12725 32768 }
12726
2/2
✓ Branch 0 taken 32768 times.
✓ Branch 1 taken 128 times.
32896 for(int32_t i=0; i<NUMSCRIPTSITEMSPRITE; i++)
12727 {
12728
1/2
✓ Branch 0 taken 32768 times.
✗ Branch 1 not taken.
32768 if (itemspritescripts[i])
12729 32768 itemspritescripts[i]->disable();
12730 else
12731 itemspritescripts[i] = new script_data(ScriptType::ItemSprite, i);
12732 32768 }
12733
2/2
✓ Branch 0 taken 65536 times.
✓ Branch 1 taken 128 times.
65664 for(int32_t i=0; i<NUMSCRIPTSCOMBODATA; i++)
12734 {
12735
1/2
✓ Branch 0 taken 65536 times.
✗ Branch 1 not taken.
65536 if (comboscripts[i])
12736 65536 comboscripts[i]->disable();
12737 else
12738 comboscripts[i] = new script_data(ScriptType::Combo, i);
12739 65536 }
12740
2/2
✓ Branch 0 taken 32768 times.
✓ Branch 1 taken 128 times.
32896 for(int32_t i=0; i<NUMSCRIPTSSUBSCREEN; i++)
12741 {
12742
1/2
✓ Branch 0 taken 32768 times.
✗ Branch 1 not taken.
32768 if (subscreenscripts[i])
12743 32768 subscreenscripts[i]->disable();
12744 else
12745 subscreenscripts[i] = new script_data(ScriptType::EngineSubscreen, i);
12746 32768 }
12747 128 }
12748
12749 extern script_command command_list[];
12750 246754 int32_t read_one_ffscript(PACKFILE *f, zquestheader *, int32_t script_index, word s_version, word , script_data **script, word zmeta_version)
12751 {
12752 // TODO: refactor to just take a script_data*
12753
1/2
✓ Branch 0 taken 246754 times.
✗ Branch 1 not taken.
246754 ASSERT(*script);
12754
12755 //Please also update loadquest() when modifying this method -DD
12756 246754 char b33[34] = {0};
12757 246754 b33[33] = 0;
12758 246754 ffscript temp_script;
12759 246754 int32_t num_commands=1000;
12760
12761
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 246754 times.
246754 if(s_version>=2)
12762 {
12763
2/4
✓ Branch 0 taken 246754 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 246754 times.
✗ Branch 3 not taken.
246754 if(!p_igetl(&num_commands,f))
12764 {
12765 return qe_invalid;
12766 }
12767 246754 }
12768
12769 #ifdef ZC_FUZZ
12770 const int32_t command_limit = 300000;
12771 #else
12772 246754 const int32_t command_limit = 10000000;
12773 #endif
12774
2/4
✓ Branch 0 taken 246754 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 246754 times.
✗ Branch 3 not taken.
246754 if (num_commands < 0 || num_commands > command_limit)
12775 {
12776 return qe_invalid;
12777 }
12778
12779
1/2
✓ Branch 0 taken 246754 times.
✗ Branch 1 not taken.
246754 (*script)->null_script(num_commands);
12780
12781
2/2
✓ Branch 0 taken 127943 times.
✓ Branch 1 taken 118811 times.
246754 if(s_version >= 16)
12782 {
12783
1/2
✓ Branch 0 taken 127943 times.
✗ Branch 1 not taken.
127943 zasm_meta temp_meta;
12784
12785
2/4
✓ Branch 0 taken 127943 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 127943 times.
✗ Branch 3 not taken.
127943 if(!p_igetw(&(temp_meta.zasm_v),f))
12786 {
12787 return qe_invalid;
12788 }
12789
12790
2/4
✓ Branch 0 taken 127943 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 127943 times.
✗ Branch 3 not taken.
127943 if(!p_igetw(&(temp_meta.meta_v),f))
12791 {
12792 return qe_invalid;
12793 }
12794
12795
2/4
✓ Branch 0 taken 127943 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 127943 times.
✗ Branch 3 not taken.
127943 if(!p_igetw(&(temp_meta.ffscript_v),f))
12796 {
12797 return qe_invalid;
12798 }
12799
12800
2/4
✓ Branch 0 taken 127943 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 127943 times.
✗ Branch 3 not taken.
127943 if(!p_getc(&(temp_meta.script_type),f))
12801 {
12802 return qe_invalid;
12803 }
12804
12805
2/2
✓ Branch 0 taken 1023544 times.
✓ Branch 1 taken 127943 times.
1151487 for(int32_t q = 0; q < 8; ++q)
12806 {
12807
2/2
✓ Branch 0 taken 57552 times.
✓ Branch 1 taken 965992 times.
1023544 if(zmeta_version < 3)
12808 {
12809
2/2
✓ Branch 0 taken 57552 times.
✓ Branch 1 taken 1899216 times.
1956768 for(int32_t c = 0; c < 33; ++c)
12810 {
12811
2/4
✓ Branch 0 taken 1899216 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1899216 times.
✗ Branch 3 not taken.
1899216 if(!p_getc(&(b33[c]),f))
12812 {
12813 return qe_invalid;
12814 }
12815 1899216 }
12816
1/2
✓ Branch 0 taken 57552 times.
✗ Branch 1 not taken.
57552 temp_meta.run_idens[q].assign(b33);
12817 57552 }
12818 else
12819 {
12820
2/4
✓ Branch 0 taken 965992 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 965992 times.
✗ Branch 3 not taken.
965992 if(!p_getcstr(&temp_meta.run_idens[q],f))
12821 {
12822 return qe_invalid;
12823 }
12824 }
12825 1023544 }
12826
12827
2/2
✓ Branch 0 taken 127943 times.
✓ Branch 1 taken 1023544 times.
1151487 for(int32_t q = 0; q < 8; ++q)
12828 {
12829
2/4
✓ Branch 0 taken 1023544 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1023544 times.
✗ Branch 3 not taken.
1023544 if(!p_getc(&(temp_meta.run_types[q]),f))
12830 {
12831 return qe_invalid;
12832 }
12833 1023544 }
12834
12835
2/4
✓ Branch 0 taken 127943 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 127943 times.
✗ Branch 3 not taken.
127943 if(!p_getc(&(temp_meta.flags),f))
12836 {
12837 return qe_invalid;
12838 }
12839
12840
2/4
✓ Branch 0 taken 127943 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 127943 times.
✗ Branch 3 not taken.
127943 if(!p_igetw(&(temp_meta.compiler_v1),f))
12841 {
12842 return qe_invalid;
12843 }
12844
12845
2/4
✓ Branch 0 taken 127943 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 127943 times.
✗ Branch 3 not taken.
127943 if(!p_igetw(&(temp_meta.compiler_v2),f))
12846 {
12847 return qe_invalid;
12848 }
12849
12850
2/4
✓ Branch 0 taken 127943 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 127943 times.
✗ Branch 3 not taken.
127943 if(!p_igetw(&(temp_meta.compiler_v3),f))
12851 {
12852 return qe_invalid;
12853 }
12854
12855
2/4
✓ Branch 0 taken 127943 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 127943 times.
✗ Branch 3 not taken.
127943 if(!p_igetw(&(temp_meta.compiler_v4),f))
12856 {
12857 return qe_invalid;
12858 }
12859
12860
2/2
✓ Branch 0 taken 7194 times.
✓ Branch 1 taken 120749 times.
127943 if(zmeta_version == 2)
12861 {
12862
2/2
✓ Branch 0 taken 7194 times.
✓ Branch 1 taken 237402 times.
244596 for(int32_t c = 0; c < 33; ++c)
12863 {
12864
2/4
✓ Branch 0 taken 237402 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 237402 times.
✗ Branch 3 not taken.
237402 if(!p_getc(&b33[c],f))
12865 {
12866 return qe_invalid;
12867 }
12868 237402 }
12869
1/2
✓ Branch 0 taken 7194 times.
✗ Branch 1 not taken.
7194 temp_meta.script_name.assign(b33);
12870
12871
2/2
✓ Branch 0 taken 7194 times.
✓ Branch 1 taken 237402 times.
244596 for(int32_t c = 0; c < 33; ++c)
12872 {
12873
2/4
✓ Branch 0 taken 237402 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 237402 times.
✗ Branch 3 not taken.
237402 if(!p_getc(&b33[c],f))
12874 {
12875 return qe_invalid;
12876 }
12877 237402 }
12878
1/2
✓ Branch 0 taken 7194 times.
✗ Branch 1 not taken.
7194 temp_meta.author.assign(b33);
12879 7194 }
12880
1/2
✓ Branch 0 taken 120749 times.
✗ Branch 1 not taken.
120749 else if(zmeta_version > 2)
12881 {
12882
2/4
✓ Branch 0 taken 120749 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 120749 times.
✗ Branch 3 not taken.
120749 if(!p_getcstr(&temp_meta.script_name,f))
12883 return qe_invalid;
12884
2/4
✓ Branch 0 taken 120749 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 120749 times.
✗ Branch 3 not taken.
120749 if(!p_getcstr(&temp_meta.author,f))
12885 return qe_invalid;
12886 120749 auto num_meta_attrib = (zmeta_version < 5 ? 4 : 10);
12887
2/2
✓ Branch 0 taken 1207490 times.
✓ Branch 1 taken 120749 times.
1328239 for(auto q = 0; q < num_meta_attrib; ++q)
12888 {
12889
2/4
✓ Branch 0 taken 1207490 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1207490 times.
✗ Branch 3 not taken.
1207490 if(!p_getcstr(&temp_meta.attributes[q],f))
12890 return qe_invalid;
12891
2/4
✓ Branch 0 taken 1207490 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1207490 times.
✗ Branch 3 not taken.
1207490 if(!p_getwstr(&temp_meta.attributes_help[q],f))
12892 return qe_invalid;
12893 1207490 }
12894
2/2
✓ Branch 0 taken 965992 times.
✓ Branch 1 taken 120749 times.
1086741 for(auto q = 0; q < 8; ++q)
12895 {
12896
2/4
✓ Branch 0 taken 965992 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 965992 times.
✗ Branch 3 not taken.
965992 if(!p_getcstr(&temp_meta.attribytes[q],f))
12897 return qe_invalid;
12898
2/4
✓ Branch 0 taken 965992 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 965992 times.
✗ Branch 3 not taken.
965992 if(!p_getwstr(&temp_meta.attribytes_help[q],f))
12899 return qe_invalid;
12900 965992 }
12901
2/2
✓ Branch 0 taken 965992 times.
✓ Branch 1 taken 120749 times.
1086741 for(auto q = 0; q < 8; ++q)
12902 {
12903
2/4
✓ Branch 0 taken 965992 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 965992 times.
✗ Branch 3 not taken.
965992 if(!p_getcstr(&temp_meta.attrishorts[q],f))
12904 return qe_invalid;
12905
2/4
✓ Branch 0 taken 965992 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 965992 times.
✗ Branch 3 not taken.
965992 if(!p_getwstr(&temp_meta.attrishorts_help[q],f))
12906 return qe_invalid;
12907 965992 }
12908
2/2
✓ Branch 0 taken 1931984 times.
✓ Branch 1 taken 120749 times.
2052733 for(auto q = 0; q < 16; ++q)
12909 {
12910
2/4
✓ Branch 0 taken 1931984 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1931984 times.
✗ Branch 3 not taken.
1931984 if(!p_getcstr(&temp_meta.usrflags[q],f))
12911 return qe_invalid;
12912
2/4
✓ Branch 0 taken 1931984 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1931984 times.
✗ Branch 3 not taken.
1931984 if(!p_getwstr(&temp_meta.usrflags_help[q],f))
12913 return qe_invalid;
12914 1931984 }
12915 120749 }
12916
2/2
✓ Branch 0 taken 120749 times.
✓ Branch 1 taken 7194 times.
127943 if(zmeta_version > 3)
12917 {
12918
2/2
✓ Branch 0 taken 965992 times.
✓ Branch 1 taken 120749 times.
1086741 for(auto q = 0; q < 8; ++q)
12919 {
12920
2/4
✓ Branch 0 taken 965992 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 965992 times.
✗ Branch 3 not taken.
965992 if(!p_getcstr(&temp_meta.initd[q],f))
12921 return qe_invalid;
12922
2/4
✓ Branch 0 taken 965992 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 965992 times.
✗ Branch 3 not taken.
965992 if(!p_getwstr(&temp_meta.initd_help[q],f))
12923 return qe_invalid;
12924 965992 }
12925
2/2
✓ Branch 0 taken 965992 times.
✓ Branch 1 taken 120749 times.
1086741 for(auto q = 0; q < 8; ++q)
12926 {
12927
2/4
✓ Branch 0 taken 965992 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 965992 times.
✗ Branch 3 not taken.
965992 if(!p_getc(&temp_meta.initd_type[q],f))
12928 return qe_invalid;
12929 965992 }
12930 120749 }
12931 else
12932 {
12933
2/2
✓ Branch 0 taken 57552 times.
✓ Branch 1 taken 7194 times.
64746 for(auto q = 0; q < 8; ++q)
12934 {
12935
1/2
✓ Branch 0 taken 57552 times.
✗ Branch 1 not taken.
57552 temp_meta.initd[q] = temp_meta.run_idens[q];
12936 57552 }
12937 }
12938
12939
1/2
✓ Branch 0 taken 127943 times.
✗ Branch 1 not taken.
127943 (*script)->meta = temp_meta;
12940
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 127943 times.
127943 }
12941
12942
1/2
✓ Branch 0 taken 246754 times.
✗ Branch 1 not taken.
246754 temp_script.clear();
12943
1/2
✓ Branch 0 taken 21805856 times.
✗ Branch 1 not taken.
21805856 for(int32_t j=0; j<num_commands; j++)
12944 {
12945
2/4
✓ Branch 0 taken 21805856 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 21805856 times.
✗ Branch 3 not taken.
21805856 if(!p_igetw(&(temp_script.command),f))
12946 {
12947 return qe_invalid;
12948 }
12949
12950
2/2
✓ Branch 0 taken 246754 times.
✓ Branch 1 taken 21559102 times.
21805856 if(temp_script.command == 0xFFFF)
12951 {
12952
1/2
✓ Branch 0 taken 246754 times.
✗ Branch 1 not taken.
246754 (*script)->zasm[j].clear();
12953 246754 break;
12954 }
12955 else
12956 {
12957
2/4
✓ Branch 0 taken 21559102 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 21559102 times.
✗ Branch 3 not taken.
21559102 if(!p_igetl(&(temp_script.arg1),f))
12958 {
12959 return qe_invalid;
12960 }
12961
12962
2/4
✓ Branch 0 taken 21559102 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 21559102 times.
✗ Branch 3 not taken.
21559102 if(!p_igetl(&(temp_script.arg2),f))
12963 {
12964 return qe_invalid;
12965 }
12966
12967
2/2
✓ Branch 0 taken 886481 times.
✓ Branch 1 taken 20672621 times.
21559102 if(s_version >= 21)
12968 {
12969 886481 uint32_t sz = 0;
12970
2/4
✓ Branch 0 taken 886481 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 886481 times.
✗ Branch 3 not taken.
886481 if(!p_igetl(&sz,f))
12971 {
12972 return qe_invalid;
12973 }
12974
2/2
✓ Branch 0 taken 3164 times.
✓ Branch 1 taken 883317 times.
886481 if(sz) //string found
12975 {
12976
1/2
✓ Branch 0 taken 3164 times.
✗ Branch 1 not taken.
3164 temp_script.strptr = new std::string();
12977 char dummy;
12978
2/2
✓ Branch 0 taken 231986 times.
✓ Branch 1 taken 3164 times.
235150 for(size_t q = 0; q < sz; ++q)
12979 {
12980
2/4
✓ Branch 0 taken 231986 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 231986 times.
✗ Branch 3 not taken.
231986 if(!p_getc(&dummy,f))
12981 {
12982 return qe_invalid;
12983 }
12984
1/2
✓ Branch 0 taken 231986 times.
✗ Branch 1 not taken.
231986 temp_script.strptr->push_back(dummy);
12985 231986 }
12986 3164 }
12987
2/4
✓ Branch 0 taken 886481 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 886481 times.
✗ Branch 3 not taken.
886481 if(!p_igetl(&sz,f))
12988 {
12989 return qe_invalid;
12990 }
12991
2/2
✓ Branch 0 taken 101 times.
✓ Branch 1 taken 886380 times.
886481 if(sz) //vector found
12992 {
12993
1/2
✓ Branch 0 taken 101 times.
✗ Branch 1 not taken.
101 temp_script.vecptr = new std::vector<int32_t>();
12994 int32_t dummy;
12995
2/2
✓ Branch 0 taken 1487 times.
✓ Branch 1 taken 101 times.
1588 for(size_t q = 0; q < sz; ++q)
12996 {
12997
2/4
✓ Branch 0 taken 1487 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1487 times.
✗ Branch 3 not taken.
1487 if(!p_igetl(&dummy,f))
12998 {
12999 return qe_invalid;
13000 }
13001
1/2
✓ Branch 0 taken 1487 times.
✗ Branch 1 not taken.
1487 temp_script.vecptr->push_back(dummy);
13002 1487 }
13003 101 }
13004 886481 }
13005
13006
1/2
✓ Branch 0 taken 21559102 times.
✗ Branch 1 not taken.
21559102 temp_script.give((*script)->zasm[j]);
13007 }
13008
1/2
✓ Branch 0 taken 21559102 times.
✗ Branch 1 not taken.
21559102 temp_script.clear();
13009 21559102 }
13010
13011
1/2
✓ Branch 0 taken 246754 times.
✗ Branch 1 not taken.
246754 (*script)->recalc_size();
13012
13013 246754 return 0;
13014 246754 }
13015
13016 extern SAMPLE customsfxdata[WAV_COUNT];
13017 extern uint8_t customsfxflag[WAV_COUNT>>3];
13018 extern int32_t sfxdat;
13019 extern DATAFILE *sfxdata;
13020 const char *old_sfx_string[Z35] =
13021 {
13022 "Arrow", "Sword beam", "Bomb blast", "Boomerang", "Subscreen cursor",
13023 "Shield is hit", "Item chime", "Roar (Dodongo, Gohma)", "Shutter", "Enemy dies",
13024 "Enemy is hit", "Low hearts warning", "Fire", "Ganon's fanfare", "Boss is hit", "Hammer",
13025 "Hookshot", "Message", "Player is hit", "Item fanfare", "Bomb placed", "Item pickup",
13026 "Refill", "Roar (Aquamentus, Gleeok, Ganon)", "Item pickup 2", "Ocean ambience",
13027 "Secret chime", "Player dies", "Stairs", "Sword", "Roar (Manhandla, Digdogger, Patra)",
13028 "Wand magic", "Whistle", "Zelda's fanfare", "Charging weapon", "Charging weapon 2",
13029 "Divine Fire", "Enemy falls from ceiling", "Divine Escape", "Fireball", "Tall Grass slashed",
13030 "Pound pounded", "Hover Boots", "Ice magic", "Jump", "Lens of Truth off", "Lens of Truth on",
13031 "Divine Protection shield", "Divine Protection 2", "Push block", "Rock", "Spell rocket down",
13032 "Spell rocket up", "Sword spin attack", "Splash", "Summon magic", "Sword tapping",
13033 "Sword tapping (secret)", "Whistle whirlwind", "Cane of Byrna orbit"
13034 };
13035 char *sfx_string[WAV_COUNT];
13036
13037 112 int32_t readsfx(PACKFILE *f, zquestheader *Header)
13038 {
13039 //these are here to bypass compiler warnings about unused arguments
13040 112 Header=Header;
13041
13042 int32_t dummy;
13043 112 word s_version=0, s_cversion=0;
13044 //int32_t ret;
13045 112 SAMPLE temp_sample = {};
13046 112 temp_sample.loop_start=0;
13047 112 temp_sample.loop_end=0;
13048 112 temp_sample.param=0;
13049
13050 //section version info
13051
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 112 times.
112 if(!p_igetw(&s_version,f))
13052 {
13053 return qe_invalid;
13054 }
13055
13056 112 FFCore.quest_format[vSFX] = s_version;
13057
13058 //al_trace("SFX version %d\n", s_version);
13059
1/2
✓ Branch 0 taken 112 times.
✗ Branch 1 not taken.
112 if(!p_igetw(&s_cversion,f))
13060 {
13061 return qe_invalid;
13062 }
13063
13064 //section size
13065
1/2
✓ Branch 0 taken 112 times.
✗ Branch 1 not taken.
112 if(!p_igetl(&dummy,f))
13066 {
13067 return qe_invalid;
13068 }
13069
13070 /* HIGHLY UNORTHODOX UPDATING THING, by L
13071 * This fixes quests made before revision 411 (such as the 'Lost Isle Build'),
13072 * where the meaning of GOTOLESS changed. It also coincided with V_SFX
13073 * changing from 1 to 2.
13074 */
13075
1/2
✓ Branch 0 taken 112 times.
✗ Branch 1 not taken.
112 if(s_version < 2)
13076 set_qr(qr_GOTOLESSNOTEQUAL,1);
13077
13078 /* End highly unorthodox updating thing */
13079
13080 112 int32_t wavcount = WAV_COUNT;
13081
13082
1/2
✓ Branch 0 taken 112 times.
✗ Branch 1 not taken.
112 if(s_version < 6)
13083 wavcount = 128;
13084
13085 uint8_t tempflag[WAV_COUNT>>3];
13086
13087
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 112 times.
112 if(s_version < 4)
13088 {
13089 memset(tempflag, 0xFF, WAV_COUNT>>3);
13090 }
13091 else
13092 {
13093
1/2
✓ Branch 0 taken 112 times.
✗ Branch 1 not taken.
112 if(s_version < 6)
13094 memset(tempflag, 0, WAV_COUNT>>3);
13095
13096
2/2
✓ Branch 0 taken 3584 times.
✓ Branch 1 taken 112 times.
3696 for(int32_t i=0; i<(wavcount>>3); i++)
13097 {
13098 3584 p_getc(&tempflag[i], f);
13099 3584 }
13100
13101 }
13102
13103
1/2
✓ Branch 0 taken 112 times.
✗ Branch 1 not taken.
112 if(s_version>4)
13104 {
13105
2/2
✓ Branch 0 taken 28560 times.
✓ Branch 1 taken 112 times.
28672 for(int32_t i=1; i<WAV_COUNT; i++)
13106 {
13107 28560 sprintf(sfx_string[i],"s%03d",i);
13108
13109
2/2
✓ Branch 0 taken 21840 times.
✓ Branch 1 taken 6720 times.
28560 if((i<Z35))
13110 6720 strcpy(sfx_string[i], old_sfx_string[i-1]);
13111
13112
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 28560 times.
28560 if(i>=wavcount)
13113 continue;
13114
2/2
✓ Branch 0 taken 2999 times.
✓ Branch 1 taken 25561 times.
28560 if(get_bit(tempflag, i-1))
13115 {
13116 char tempname[36];
13117
13118
1/2
✓ Branch 0 taken 2999 times.
✗ Branch 1 not taken.
2999 if(!pfread(tempname, 36, f))
13119 {
13120 return qe_invalid;
13121 }
13122
13123 2999 sfx_string[i][0] = '\0';
13124 2999 strncat(sfx_string[i], tempname, 36 - 1);
13125 2999 }
13126 else
13127 {
13128 25561 sprintf(sfx_string[i],"s%03d",i);
13129
13130
2/2
✓ Branch 0 taken 20983 times.
✓ Branch 1 taken 4578 times.
25561 if(i<Z35)
13131 4578 strcpy(sfx_string[i], old_sfx_string[i-1]);
13132 25561 sfx_string[i][35] = 0; //Force NULL Termination
13133 }
13134 28560 }
13135 112 }
13136 else
13137 {
13138 for(int32_t i=1; i<WAV_COUNT; i++)
13139 {
13140 sprintf(sfx_string[i],"s%03d",i);
13141
13142 if(i<Z35)
13143 strcpy(sfx_string[i], old_sfx_string[i-1]);
13144 }
13145 }
13146
13147 //finally... section data
13148
2/2
✓ Branch 0 taken 28560 times.
✓ Branch 1 taken 112 times.
28672 for(int32_t i=1; i<wavcount; i++)
13149 {
13150
2/2
✓ Branch 0 taken 2999 times.
✓ Branch 1 taken 25561 times.
28560 if(get_bit(tempflag, i-1))
13151 {
13152
13153
1/2
✓ Branch 0 taken 2999 times.
✗ Branch 1 not taken.
2999 if(!p_igetl(&dummy,f))
13154 {
13155 return qe_invalid;
13156 }
13157
13158 2999 (temp_sample.bits) = dummy;
13159
13160
1/2
✓ Branch 0 taken 2999 times.
✗ Branch 1 not taken.
2999 if(!p_igetl(&dummy,f))
13161 {
13162 return qe_invalid;
13163 }
13164
13165 2999 (temp_sample.stereo) = dummy;
13166
13167
1/2
✓ Branch 0 taken 2999 times.
✗ Branch 1 not taken.
2999 if(!p_igetl(&dummy,f))
13168 {
13169 return qe_invalid;
13170 }
13171
13172 2999 (temp_sample.freq) = dummy;
13173
13174
1/2
✓ Branch 0 taken 2999 times.
✗ Branch 1 not taken.
2999 if(!p_igetl(&dummy,f))
13175 {
13176 return qe_invalid;
13177 }
13178
13179 2999 (temp_sample.priority) = dummy;
13180
13181
1/2
✓ Branch 0 taken 2999 times.
✗ Branch 1 not taken.
2999 if(!p_igetl(&(temp_sample.len),f))
13182 {
13183 return qe_invalid;
13184 }
13185
13186
1/2
✓ Branch 0 taken 2999 times.
✗ Branch 1 not taken.
2999 if(!p_igetl(&(temp_sample.loop_start),f))
13187 {
13188 return qe_invalid;
13189 }
13190
13191
1/2
✓ Branch 0 taken 2999 times.
✗ Branch 1 not taken.
2999 if(!p_igetl(&(temp_sample.loop_end),f))
13192 {
13193 return qe_invalid;
13194 }
13195
13196
1/2
✓ Branch 0 taken 2999 times.
✗ Branch 1 not taken.
2999 if(!p_igetl(&(temp_sample.param),f))
13197 {
13198 return qe_invalid;
13199 }
13200
13201 // al_trace("F%i: L%i\n",i,temp_sample.len);
13202 // temp_sample.data = new byte[(temp_sample.bits==8?1:2)*temp_sample.len];
13203 2999 auto len = (temp_sample.bits==8?1:2)*(temp_sample.stereo==0?1:2)*temp_sample.len;
13204
2/4
✓ Branch 0 taken 2999 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2999 times.
2999 if (len < 0 || len > 10000000)
13205 {
13206 return qe_invalid;
13207 }
13208 2999 temp_sample.data = calloc(len,1);
13209
13210
1/2
✓ Branch 0 taken 2999 times.
✗ Branch 1 not taken.
2999 if(s_version < 3)
13211 len = (temp_sample.bits==8?1:2)*temp_sample.len;
13212
13213 //old-style, non-portable loading (Bad Allegro! Bad!!) -DD
13214
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2999 times.
2999 if(s_version < 2)
13215 {
13216 if(!pfread(temp_sample.data, len,f))
13217 {
13218 return qe_invalid;
13219 }
13220 }
13221 else
13222 {
13223 //re-endianfy the data
13224 2999 int32_t wordstoread = len / sizeof(word);
13225
13226
2/2
✓ Branch 0 taken 87343682 times.
✓ Branch 1 taken 2999 times.
87346681 for(int32_t j=0; j<wordstoread; j++)
13227 {
13228 word temp;
13229
13230
1/2
✓ Branch 0 taken 87343682 times.
✗ Branch 1 not taken.
87343682 if(!p_igetw(&temp, f))
13231 {
13232 return qe_invalid;
13233 }
13234
13235 87343682 ((word *)temp_sample.data)[j] = temp;
13236 87343682 }
13237 }
13238 2999 }
13239
2/2
✓ Branch 0 taken 4578 times.
✓ Branch 1 taken 20983 times.
25561 else if(i < Z35)
13240 {
13241 4578 SAMPLE* datsamp = (SAMPLE*)(sfxdata[i].dat);
13242 4578 memcpy(&temp_sample, datsamp, sizeof(SAMPLE));
13243 4578 set_bit(tempflag, i-1, 1);
13244 4578 int32_t len = (temp_sample.bits==8?1:2)*(temp_sample.stereo==0?1:2)*temp_sample.len;
13245 4578 temp_sample.data = calloc(len,1);
13246 4578 memcpy(temp_sample.data, datsamp->data, len);
13247 4578 }
13248 20983 else continue;
13249
13250
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7577 times.
7577 if(customsfxdata[i].data!=NULL)
13251 {
13252 // delete [] customsfxdata[i].data;
13253 7577 free(customsfxdata[i].data);
13254 7577 }
13255
13256 // customsfxdata[i].data = new byte[(temp_sample.bits==8?1:2)*temp_sample.len];
13257 7577 int32_t len2 = (temp_sample.bits==8?1:2)*(temp_sample.stereo==0?1:2)*temp_sample.len;
13258 7577 customsfxdata[i].data = calloc(len2,1);
13259 7577 customsfxdata[i].bits = temp_sample.bits;
13260 7577 customsfxdata[i].stereo = temp_sample.stereo;
13261 7577 customsfxdata[i].freq = temp_sample.freq;
13262 7577 customsfxdata[i].priority = temp_sample.priority;
13263 7577 customsfxdata[i].len = temp_sample.len;
13264 7577 customsfxdata[i].loop_start = temp_sample.loop_start;
13265 7577 customsfxdata[i].loop_end = temp_sample.loop_end;
13266 7577 customsfxdata[i].param = temp_sample.param;
13267 7577 int32_t cpylen = len2;
13268
13269
1/2
✓ Branch 0 taken 7577 times.
✗ Branch 1 not taken.
7577 if(s_version<3)
13270 {
13271 cpylen = (temp_sample.bits==8?1:2)*temp_sample.len;
13272 al_trace("WARNING: Quest SFX %d is in stereo, and may be corrupt.\n",i);
13273 }
13274
13275 7577 memcpy(customsfxdata[i].data,temp_sample.data,cpylen);
13276
13277 7577 free(temp_sample.data);
13278 7577 }
13279
13280 112 memcpy(customsfxflag, tempflag, WAV_COUNT>>3);
13281
13282 112 sfxdat=0;
13283 112 return 0;
13284 112 }
13285
13286 128 void setupsfx()
13287 {
13288
2/2
✓ Branch 0 taken 32640 times.
✓ Branch 1 taken 128 times.
32768 for(int32_t i=1; i<WAV_COUNT; i++)
13289 {
13290 32640 sprintf(sfx_string[i],"s%03d",i);
13291
13292
2/2
✓ Branch 0 taken 24960 times.
✓ Branch 1 taken 7680 times.
32640 if(i<Z35)
13293 {
13294 7680 strcpy(sfx_string[i], old_sfx_string[i-1]);
13295 7680 }
13296
13297 32640 memset(customsfxflag, 0, WAV_COUNT>>3);
13298
13299 32640 int32_t j=i;
13300
13301
2/2
✓ Branch 0 taken 7808 times.
✓ Branch 1 taken 24832 times.
32640 if(i>Z35)
13302 {
13303 24832 i=Z35;
13304 24832 }
13305
13306 32640 SAMPLE *temp_sample = (SAMPLE *)sfxdata[i].dat;
13307
13308
2/2
✓ Branch 0 taken 29070 times.
✓ Branch 1 taken 3570 times.
32640 if(customsfxdata[j].data!=NULL)
13309 {
13310 // delete [] customsfxdata[j].data;
13311 3570 free(customsfxdata[j].data);
13312 3570 }
13313
13314 // customsfxdata[j].data = new byte[(temp_sample->bits==8?1:2)*temp_sample->len];
13315 32640 customsfxdata[j].data = calloc((temp_sample->bits==8?1:2)*(temp_sample->stereo == 0 ? 1 : 2)*temp_sample->len,1);
13316 32640 customsfxdata[j].bits = temp_sample->bits;
13317 32640 customsfxdata[j].stereo = temp_sample->stereo;
13318 32640 customsfxdata[j].freq = temp_sample->freq;
13319 32640 customsfxdata[j].priority = temp_sample->priority;
13320 32640 customsfxdata[j].len = temp_sample->len;
13321 32640 customsfxdata[j].loop_start = temp_sample->loop_start;
13322 32640 customsfxdata[j].loop_end = temp_sample->loop_end;
13323 32640 customsfxdata[j].param = temp_sample->param;
13324 32640 memcpy(customsfxdata[j].data, (temp_sample->data), (temp_sample->bits==8?1:2)*(temp_sample->stereo==0 ? 1 : 2)*temp_sample->len);
13325 32640 i=j;
13326 32640 }
13327 128 }
13328
13329 extern char *guy_string[eMAXGUYS];
13330 extern const char *old_guy_string[OLDMAXGUYS];
13331
13332 128 int32_t readguys(PACKFILE *f, zquestheader *Header)
13333 {
13334
2/2
✓ Branch 0 taken 124 times.
✓ Branch 1 taken 4 times.
128 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_guys);
13335
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 128 times.
128 if (should_skip) return 0;
13336
13337 dword dummy;
13338 word guy_cversion;
13339 128 word guyversion=0;
13340
13341
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 124 times.
128 if(Header->zelda_version >= 0x193)
13342 {
13343 //section version info
13344
1/2
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
124 if(!p_igetw(&guyversion,f))
13345 {
13346 return qe_invalid;
13347 }
13348
13349 124 FFCore.quest_format[vGuys] = guyversion;
13350
13351 //al_trace("Guys version %d\n", guyversion);
13352
1/2
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
124 if(!p_igetw(&guy_cversion,f))
13353 {
13354 return qe_invalid;
13355 }
13356 124 al_trace("Guy CVersion is: %d\n", guy_cversion);
13357 //section size
13358
1/2
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
124 if(!p_igetl(&dummy,f))
13359 {
13360 return qe_invalid;
13361 }
13362 124 }
13363
13364
2/2
✓ Branch 0 taken 112 times.
✓ Branch 1 taken 16 times.
128 if(guyversion > 3)
13365 {
13366
2/2
✓ Branch 0 taken 57344 times.
✓ Branch 1 taken 112 times.
57456 for(int32_t i=0; i<MAXGUYS; i++)
13367 {
13368 char tempname[64];
13369
13370 // rev. 1511 : guyversion = 23. upped to 512 editable enemies. -Gleeok
13371 // if guyversion < 23 then there is only 256 enemies in the packfile, so default the rest.
13372
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 57344 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
57344 if(guyversion < 23 && i >= OLDBETAMAXGUYS)
13373 {
13374 memset(tempname, 0, sizeof(char)*64);
13375 sprintf(tempname, "e%03d", i);
13376 strcpy(guy_string[i], tempname);
13377
13378 continue;
13379 }
13380
13381
1/2
✓ Branch 0 taken 57344 times.
✗ Branch 1 not taken.
57344 if(!pfread(tempname, 64, f))
13382 {
13383 return qe_invalid;
13384 }
13385
13386 // Don't retain names of uneditable enemy entries!
13387 // for version upgrade to 2.5
13388
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 57344 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
57344 if(guyversion < 23 && i >= 177)
13389 {
13390 // some of the older builds have names such as 'zz123',
13391 // (this order gets messed up with some eXXX and some zzXXX)
13392 // so let's update to the newer naming convection. -Gleeok
13393 char tmpbuf[64];
13394 memset(tmpbuf, 0, sizeof(char)*64);
13395 sprintf(tmpbuf, "zz%03d", i);
13396
13397 if(memcmp(tempname, tmpbuf, size_t(5)) == 0)
13398 {
13399 memset(tempname, 0, sizeof(char)*64);
13400 sprintf(tempname, "e%03d", i);
13401 }
13402 }
13403
13404
6/6
✓ Branch 0 taken 19824 times.
✓ Branch 1 taken 37520 times.
✓ Branch 2 taken 18816 times.
✓ Branch 3 taken 1008 times.
✓ Branch 4 taken 15792 times.
✓ Branch 5 taken 3024 times.
57344 if(i >= OLDMAXGUYS || strlen(tempname)<1 || tempname[strlen(tempname)-1]!=' ')
13405 {
13406 54320 guy_string[i][0] = '\0';
13407 54320 strncat(guy_string[i], tempname, 64 - 1);
13408 54320 }
13409 else
13410 {
13411 3024 strcpy(guy_string[i],old_guy_string[i]);
13412 }
13413 57344 }
13414 112 }
13415 else
13416 {
13417
2/2
✓ Branch 0 taken 8192 times.
✓ Branch 1 taken 16 times.
8208 for(int32_t i=0; i<eMAXGUYS; i++)
13418 {
13419 8192 sprintf(guy_string[i],"zz%03d",i);
13420 8192 }
13421
13422
2/2
✓ Branch 0 taken 2832 times.
✓ Branch 1 taken 16 times.
2848 for(int32_t i=0; i<OLDMAXGUYS; i++)
13423 {
13424 2832 strcpy(guy_string[i],old_guy_string[i]);
13425 2832 }
13426 }
13427
13428
13429 //finally... section data
13430 128 init_guys(guyversion); //using default data for now...
13431
13432 // Goriya guy fix
13433
3/6
✓ Branch 0 taken 112 times.
✓ Branch 1 taken 16 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 112 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
128 if((Header->zelda_version < 0x211)||((Header->zelda_version == 0x211)&&(Header->build<7)))
13434 {
13435
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 12 times.
16 if(get_qr(qr_NEWENEMYTILES))
13436 {
13437 12 guysbuf[gGORIYA].tile=130;
13438 12 guysbuf[gGORIYA].e_tile=130;
13439 12 }
13440 16 }
13441
13442
2/2
✓ Branch 0 taken 124 times.
✓ Branch 1 taken 4 times.
128 if(Header->zelda_version < 0x193)
13443 {
13444
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(get_bit(deprecated_rules,46))
13445 {
13446 guysbuf[eDODONGO].cset=14;
13447 guysbuf[eDODONGO].bosspal=spDIG;
13448 }
13449 4 }
13450 // Not sure when this first changed, but it's necessary for 2.10, at least
13451 // @TODO: @BUG:1.92 - 1.84? Figure this out exactly for the final 2.50 release.
13452 //2.10 Fixes
13453
3/6
✓ Branch 0 taken 112 times.
✓ Branch 1 taken 16 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 112 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
128 if((Header->zelda_version < 0x211)||((Header->zelda_version == 0x211)&&(Header->build<18)))
13454 {
13455 16 guysbuf[eWWIZ].editorflags |= ENEMY_FLAG5;
13456 16 guysbuf[eMOLDORM].editorflags |= ENEMY_FLAG6;
13457 16 guysbuf[eMANHAN].editorflags |= ENEMY_FLAG6;
13458 16 guysbuf[eCENT1].misc3 = 1;
13459 16 guysbuf[eCENT2].misc3 = 1;
13460 16 }
13461
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 128 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
128 if((Header->zelda_version <= 0x255) || (Header->zelda_version == 0x255 && Header->build < 47) )
13462 {
13463 128 guysbuf[eWPOLSV].defense[edefWhistle] = ed1HKO;
13464 128 }
13465
2/2
✓ Branch 0 taken 112 times.
✓ Branch 1 taken 16 times.
128 if(Header->zelda_version <= 0x210)
13466 {
13467 16 guysbuf[eGLEEOK1F].misc6 = 16;
13468 16 guysbuf[eGLEEOK2F].misc6 = 16;
13469 16 guysbuf[eGLEEOK3F].misc6 = 16;
13470 16 guysbuf[eGLEEOK4F].misc6 = 16;
13471
13472 16 guysbuf[eWIZ1].misc4 = 1; //only set the enemy that needs backward compat, not all of them.
13473 16 guysbuf[eBATROBE].misc4 = 1;
13474 //guysbuf[eSUMMONER].misc4 = 1;
13475 16 guysbuf[eWWIZ].misc4 = 1;
13476 16 guysbuf[eDODONGO].deadsfx = 15; //In 2.10 and earlier, Dodongos used this as their death sound.
13477 16 guysbuf[eDODONGOBS].deadsfx = 15; //In 2.10 and earlier, Dodongos used this as their death sound.
13478 16 }
13479
2/2
✓ Branch 0 taken 124 times.
✓ Branch 1 taken 4 times.
128 if(Header->zelda_version == 0x190)
13480 {
13481 4 al_trace("Setting Tribble Properties for Version: %x", Header->zelda_version);
13482 4 guysbuf[eKEESETRIB].misc3 = eVIRE; //1.90 and earlier, keese and gel tribbles grew up into
13483 4 guysbuf[eGELTRIB].misc3 = eZOL; //normal vires, and zols -Z (16th January, 2019 )
13484 4 }
13485
13486 // The versions here may not be correct
13487 // zelda_version>=0x211 handled at guyversion<24
13488
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 124 times.
128 if(Header->zelda_version <= 0x190)
13489 {
13490 4 guysbuf[eCENT1].misc3 = 0;
13491 4 guysbuf[eCENT2].misc3 = 0;
13492 4 guysbuf[eMOLDORM].misc2 = 0;
13493 //guysbuf[eKEESETRIB].misc3 = eVIRE; //1.90 and earlier, keese and gel tribbles grew up into
13494 //guysbuf[eGELTRIB].misc3 = eZOL; //normal vires, and zols -Z (16th January, 2019 )
13495 4 }
13496
2/2
✓ Branch 0 taken 112 times.
✓ Branch 1 taken 12 times.
124 else if(Header->zelda_version <= 0x210)
13497 {
13498 12 guysbuf[eCENT1].misc3 = 1;
13499 12 guysbuf[eCENT2].misc3 = 1;
13500 12 guysbuf[eMOLDORM].misc2 = 0;
13501 12 }
13502
13503
2/2
✓ Branch 0 taken 112 times.
✓ Branch 1 taken 16 times.
128 if ( Header->zelda_version < 0x211 ) //Default rest rates for phantom ghinis, peahats and keese in < 2.50 quests
13504 {
13505 16 guysbuf[eKEESE1].misc16 = 120;
13506 16 guysbuf[eKEESE2].misc16 = 120;
13507 16 guysbuf[eKEESE3].misc16 = 120;
13508 16 guysbuf[eKEESETRIB].misc16 = 120;
13509 16 guysbuf[eKEESE1].misc17 = 16;
13510 16 guysbuf[eKEESE2].misc17 = 16;
13511 16 guysbuf[eKEESE3].misc17 = 16;
13512 16 guysbuf[eKEESETRIB].misc17 = 16;
13513
13514 16 guysbuf[ePEAHAT].misc16 = 80;
13515 16 guysbuf[ePEAHAT].misc17 = 16;
13516
13517 16 guysbuf[eGHINI2].misc16 = 120;
13518 16 guysbuf[eGHINI2].misc17 = 10;
13519
13520
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if (replay_version_check(20))
13521 {
13522 guysbuf[eGHINI2].moveflags |= (FLAG_CAN_WATERWALK|FLAG_CAN_PITWALK);
13523 guysbuf[eMOLDORM].moveflags |= (FLAG_CAN_WATERWALK|FLAG_CAN_PITWALK);
13524 guysbuf[eKEESETRIB].moveflags |= (FLAG_CAN_WATERWALK|FLAG_CAN_PITWALK);
13525 guysbuf[eKEESE3].moveflags |= (FLAG_CAN_WATERWALK|FLAG_CAN_PITWALK);
13526 guysbuf[eKEESE2].moveflags |= (FLAG_CAN_WATERWALK|FLAG_CAN_PITWALK);
13527 guysbuf[eKEESE1].moveflags |= (FLAG_CAN_WATERWALK|FLAG_CAN_PITWALK);
13528 guysbuf[eTEK1].moveflags |= (FLAG_CAN_WATERWALK|FLAG_CAN_PITWALK);
13529 guysbuf[eTEK2].moveflags |= (FLAG_CAN_WATERWALK|FLAG_CAN_PITWALK);
13530 guysbuf[ePEAHAT].moveflags |= (FLAG_CAN_WATERWALK|FLAG_CAN_PITWALK);
13531 guysbuf[eROCK].moveflags |= (FLAG_CAN_WATERWALK|FLAG_CAN_PITWALK);
13532 guysbuf[eTRAP].moveflags |= (FLAG_CAN_WATERWALK|FLAG_CAN_PITWALK);
13533 guysbuf[eWALLM].moveflags |= (FLAG_CAN_WATERWALK|FLAG_CAN_PITWALK);
13534 guysbuf[ePOLSV].moveflags |= (FLAG_CAN_WATERWALK|FLAG_CAN_PITWALK);
13535 guysbuf[eMANHAN].moveflags |= (FLAG_CAN_WATERWALK|FLAG_CAN_PITWALK);
13536 guysbuf[eGLEEOK1].moveflags |= (FLAG_CAN_WATERWALK|FLAG_CAN_PITWALK);
13537 guysbuf[eGLEEOK2].moveflags |= (FLAG_CAN_WATERWALK|FLAG_CAN_PITWALK);
13538 guysbuf[eGLEEOK3].moveflags |= (FLAG_CAN_WATERWALK|FLAG_CAN_PITWALK);
13539 guysbuf[eGLEEOK4].moveflags |= (FLAG_CAN_WATERWALK|FLAG_CAN_PITWALK);
13540 guysbuf[eDIG1].moveflags |= (FLAG_CAN_WATERWALK|FLAG_CAN_PITWALK);
13541 guysbuf[eDIG3].moveflags |= (FLAG_CAN_WATERWALK|FLAG_CAN_PITWALK);
13542 guysbuf[eDIGPUP1].moveflags |= (FLAG_CAN_WATERWALK|FLAG_CAN_PITWALK);
13543 guysbuf[eDIGPUP2].moveflags |= (FLAG_CAN_WATERWALK|FLAG_CAN_PITWALK);
13544 guysbuf[eDIGPUP3].moveflags |= (FLAG_CAN_WATERWALK|FLAG_CAN_PITWALK);
13545 guysbuf[eDIGPUP4].moveflags |= (FLAG_CAN_WATERWALK|FLAG_CAN_PITWALK);
13546 guysbuf[eRAQUAM].moveflags |= (FLAG_CAN_WATERWALK|FLAG_CAN_PITWALK);
13547 guysbuf[eITEMFAIRY].moveflags |= (FLAG_CAN_WATERWALK|FLAG_CAN_PITWALK);
13548 guysbuf[eFIRE].moveflags |= (FLAG_CAN_WATERWALK|FLAG_CAN_PITWALK);
13549 guysbuf[eMANHAN2].moveflags |= (FLAG_CAN_WATERWALK|FLAG_CAN_PITWALK);
13550 guysbuf[eTRAP_H].moveflags |= (FLAG_CAN_WATERWALK|FLAG_CAN_PITWALK);
13551 guysbuf[eTRAP_V].moveflags |= (FLAG_CAN_WATERWALK|FLAG_CAN_PITWALK);
13552 guysbuf[eTRAP_LR].moveflags |= (FLAG_CAN_WATERWALK|FLAG_CAN_PITWALK);
13553 guysbuf[eTRAP_UD].moveflags |= (FLAG_CAN_WATERWALK|FLAG_CAN_PITWALK);
13554 guysbuf[ePATRA1].moveflags |= (FLAG_CAN_WATERWALK|FLAG_CAN_PITWALK);
13555 guysbuf[ePATRA2].moveflags |= (FLAG_CAN_WATERWALK|FLAG_CAN_PITWALK);
13556 guysbuf[ePATRABS].moveflags |= (FLAG_CAN_WATERWALK|FLAG_CAN_PITWALK);
13557 guysbuf[eBAT].moveflags |= (FLAG_CAN_WATERWALK|FLAG_CAN_PITWALK);
13558 guysbuf[eGLEEOK1F].moveflags |= (FLAG_CAN_WATERWALK|FLAG_CAN_PITWALK);
13559 guysbuf[eGLEEOK2F].moveflags |= (FLAG_CAN_WATERWALK|FLAG_CAN_PITWALK);
13560 guysbuf[eGLEEOK3F].moveflags |= (FLAG_CAN_WATERWALK|FLAG_CAN_PITWALK);
13561 guysbuf[eGLEEOK4F].moveflags |= (FLAG_CAN_WATERWALK|FLAG_CAN_PITWALK);
13562 guysbuf[eTRIGGER].moveflags |= (FLAG_CAN_WATERWALK|FLAG_CAN_PITWALK);
13563 guysbuf[ePATRAL2].moveflags |= (FLAG_CAN_WATERWALK|FLAG_CAN_PITWALK);
13564 guysbuf[ePATRAL3].moveflags |= (FLAG_CAN_WATERWALK|FLAG_CAN_PITWALK);
13565 guysbuf[eGOHMA1].moveflags |= (FLAG_CAN_WATERWALK|FLAG_CAN_PITWALK);
13566 guysbuf[eGOHMA2].moveflags |= (FLAG_CAN_WATERWALK|FLAG_CAN_PITWALK);
13567 guysbuf[eGOHMA3].moveflags |= (FLAG_CAN_WATERWALK|FLAG_CAN_PITWALK);
13568 guysbuf[eGOHMA4].moveflags |= (FLAG_CAN_WATERWALK|FLAG_CAN_PITWALK);
13569 guysbuf[eMPOLSV].moveflags |= (FLAG_CAN_WATERWALK|FLAG_CAN_PITWALK);
13570 guysbuf[eWPOLSV].moveflags |= (FLAG_CAN_WATERWALK|FLAG_CAN_PITWALK);
13571 }
13572 16 }
13573
13574
13575
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 112 times.
128 if(guyversion<=2)
13576 {
13577 16 return readherosprites2(f, guyversion==2?0:-1, 0);
13578 }
13579
13580
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 112 times.
112 if(guyversion > 3)
13581 {
13582 guydata tempguy;
13583
13584
2/2
✓ Branch 0 taken 57344 times.
✓ Branch 1 taken 112 times.
57456 for(int32_t i=0; i<MAXGUYS; i++)
13585 {
13586
1/2
✓ Branch 0 taken 57344 times.
✗ Branch 1 not taken.
57344 if(guyversion < 23) // May 2012 : 512 max enemies
13587 {
13588 if(i >= OLDBETAMAXGUYS)
13589 {
13590 memset(&guysbuf[i], 0, sizeof(guydata));
13591 continue;
13592 }
13593 }
13594
13595 57344 memset(&tempguy, 0, sizeof(guydata));
13596
13597
1/2
✓ Branch 0 taken 57344 times.
✗ Branch 1 not taken.
57344 if(!p_igetl(&(tempguy.flags),f))
13598 {
13599 return qe_invalid;
13600 }
13601
13602
1/2
✓ Branch 0 taken 57344 times.
✗ Branch 1 not taken.
57344 if(!p_igetl(&(tempguy.flags2),f))
13603 {
13604 return qe_invalid;
13605 }
13606
13607
2/2
✓ Branch 0 taken 17920 times.
✓ Branch 1 taken 39424 times.
57344 if ( guyversion >= 36 ) //expanded tiles
13608 {
13609
1/2
✓ Branch 0 taken 17920 times.
✗ Branch 1 not taken.
17920 if(!p_igetl(&(tempguy.tile),f))
13610 {
13611 return qe_invalid;
13612 }
13613 17920 }
13614 else
13615 {
13616
1/2
✓ Branch 0 taken 39424 times.
✗ Branch 1 not taken.
39424 if(!p_igetw(&(tempguy.tile),f))
13617 {
13618 return qe_invalid;
13619 }
13620 }
13621
1/2
✓ Branch 0 taken 57344 times.
✗ Branch 1 not taken.
57344 if(!p_getc(&(tempguy.width),f))
13622 {
13623 return qe_invalid;
13624 }
13625
13626
1/2
✓ Branch 0 taken 57344 times.
✗ Branch 1 not taken.
57344 if(!p_getc(&(tempguy.height),f))
13627 {
13628 return qe_invalid;
13629 }
13630
13631
2/2
✓ Branch 0 taken 17920 times.
✓ Branch 1 taken 39424 times.
57344 if ( guyversion >= 36 ) //expanded tiles
13632 {
13633
1/2
✓ Branch 0 taken 17920 times.
✗ Branch 1 not taken.
17920 if(!p_igetl(&(tempguy.s_tile),f))
13634 {
13635 return qe_invalid;
13636 }
13637 17920 }
13638 else
13639 {
13640
1/2
✓ Branch 0 taken 39424 times.
✗ Branch 1 not taken.
39424 if(!p_igetw(&(tempguy.s_tile),f))
13641 {
13642 return qe_invalid;
13643 }
13644 }
13645
13646
1/2
✓ Branch 0 taken 57344 times.
✗ Branch 1 not taken.
57344 if(!p_getc(&(tempguy.s_width),f))
13647 {
13648 return qe_invalid;
13649 }
13650
13651
1/2
✓ Branch 0 taken 57344 times.
✗ Branch 1 not taken.
57344 if(!p_getc(&(tempguy.s_height),f))
13652 {
13653 return qe_invalid;
13654 }
13655
13656
2/2
✓ Branch 0 taken 17920 times.
✓ Branch 1 taken 39424 times.
57344 if ( guyversion >= 36 ) //expanded tiles
13657 {
13658
1/2
✓ Branch 0 taken 17920 times.
✗ Branch 1 not taken.
17920 if(!p_igetl(&(tempguy.e_tile),f))
13659 {
13660 return qe_invalid;
13661 }
13662 17920 }
13663 else
13664 {
13665
1/2
✓ Branch 0 taken 39424 times.
✗ Branch 1 not taken.
39424 if(!p_igetw(&(tempguy.e_tile),f))
13666 {
13667 return qe_invalid;
13668 }
13669 }
13670
13671
1/2
✓ Branch 0 taken 57344 times.
✗ Branch 1 not taken.
57344 if(!p_getc(&(tempguy.e_width),f))
13672 {
13673 return qe_invalid;
13674 }
13675
13676
1/2
✓ Branch 0 taken 57344 times.
✗ Branch 1 not taken.
57344 if(!p_getc(&(tempguy.e_height),f))
13677 {
13678 return qe_invalid;
13679 }
13680
13681
1/2
✓ Branch 0 taken 57344 times.
✗ Branch 1 not taken.
57344 if(!p_igetw(&(tempguy.hp),f))
13682 {
13683 return qe_invalid;
13684 }
13685
13686
1/2
✓ Branch 0 taken 57344 times.
✗ Branch 1 not taken.
57344 if(!p_igetw(&(tempguy.family),f))
13687 {
13688 return qe_invalid;
13689 }
13690
13691
1/12
✗ Branch 0 not taken.
✓ Branch 1 taken 57344 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
57344 if(guyversion < 9 && (i==eDKNUT1 || i==eDKNUT2 || i==eDKNUT3 || i==eDKNUT4 || i==eDKNUT5)) // Whoops, forgot about Darknuts...
13692 {
13693 if(get_qr(qr_NEWENEMYTILES))
13694 {
13695 tempguy.s_tile=tempguy.e_tile+120;
13696 tempguy.s_width=tempguy.e_width;
13697 tempguy.s_height=tempguy.e_height;
13698 }
13699 else tempguy.s_tile=860;
13700 }
13701
13702
1/2
✓ Branch 0 taken 57344 times.
✗ Branch 1 not taken.
57344 if(!p_igetw(&(tempguy.cset),f))
13703 {
13704 return qe_invalid;
13705 }
13706
13707
1/2
✓ Branch 0 taken 57344 times.
✗ Branch 1 not taken.
57344 if(!p_igetw(&(tempguy.anim),f))
13708 {
13709 return qe_invalid;
13710 }
13711
13712
1/2
✓ Branch 0 taken 57344 times.
✗ Branch 1 not taken.
57344 if(!p_igetw(&(tempguy.e_anim),f))
13713 {
13714 return qe_invalid;
13715 }
13716
13717
1/2
✓ Branch 0 taken 57344 times.
✗ Branch 1 not taken.
57344 if(!p_igetw(&(tempguy.frate),f))
13718 {
13719 return qe_invalid;
13720 }
13721
13722
1/2
✓ Branch 0 taken 57344 times.
✗ Branch 1 not taken.
57344 if(!p_igetw(&(tempguy.e_frate),f))
13723 {
13724 return qe_invalid;
13725 }
13726
13727
1/2
✓ Branch 0 taken 57344 times.
✗ Branch 1 not taken.
57344 if(guyversion < 13) // April 2009
13728 {
13729 if(get_bit(deprecated_rules, qr_SLOWENEMYANIM_DEP))
13730 {
13731 tempguy.frate *= 2;
13732 tempguy.e_frate *= 2;
13733 }
13734 }
13735
13736
1/2
✓ Branch 0 taken 57344 times.
✗ Branch 1 not taken.
57344 if(guyversion < 14) // May 1 2009
13737 {
13738 if(tempguy.anim==a2FRMSLOW)
13739 {
13740 tempguy.anim=a2FRM;
13741 tempguy.frate *= 2;
13742 }
13743
13744 if(tempguy.e_anim==a2FRMSLOW)
13745 {
13746 tempguy.e_anim=a2FRM;
13747 tempguy.e_frate *= 2;
13748 }
13749
13750 if(tempguy.anim==aFLIPSLOW)
13751 {
13752 tempguy.anim=aFLIP;
13753 tempguy.frate *= 2;
13754 }
13755
13756 if(tempguy.e_anim==aFLIPSLOW)
13757 {
13758 tempguy.e_anim=aFLIP;
13759 tempguy.e_frate *= 2;
13760 }
13761
13762 if(tempguy.anim == aNEWDWALK) tempguy.anim = a4FRM4DIR;
13763
13764 if(tempguy.e_anim == aNEWDWALK) tempguy.e_anim = a4FRM4DIR;
13765
13766 if(tempguy.anim == aNEWPOLV || tempguy.anim == a4FRM3TRAP)
13767 {
13768 tempguy.anim=a4FRM4DIR;
13769 tempguy.s_tile=(get_qr(qr_NEWENEMYTILES) ? tempguy.e_tile : tempguy.tile)+20;
13770 }
13771
13772 if(tempguy.e_anim == aNEWPOLV || tempguy.e_anim == a4FRM3TRAP)
13773 {
13774 tempguy.e_anim=a4FRM4DIR;
13775 tempguy.s_tile=(get_qr(qr_NEWENEMYTILES) ? tempguy.e_tile : tempguy.tile)+20;
13776 }
13777 }
13778
13779
1/2
✓ Branch 0 taken 57344 times.
✗ Branch 1 not taken.
57344 if(!p_igetw(&(tempguy.dp),f))
13780 {
13781 return qe_invalid;
13782 }
13783
13784 //correction for guy fire
13785
1/2
✓ Branch 0 taken 57344 times.
✗ Branch 1 not taken.
57344 if(guyversion < 6)
13786 {
13787 if(i == gFIRE)
13788 tempguy.dp = 2;
13789 }
13790
13791
1/2
✓ Branch 0 taken 57344 times.
✗ Branch 1 not taken.
57344 if(!p_igetw(&(tempguy.wdp),f))
13792 {
13793 return qe_invalid;
13794 }
13795
13796
1/2
✓ Branch 0 taken 57344 times.
✗ Branch 1 not taken.
57344 if(!p_igetw(&(tempguy.weapon),f))
13797 {
13798 return qe_invalid;
13799 }
13800
13801 //correction for bosses using triple, "rising" fireballs
13802
1/2
✓ Branch 0 taken 57344 times.
✗ Branch 1 not taken.
57344 if(guyversion < 5)
13803 {
13804 if(i == eLAQUAM || i == eRAQUAM || i == eGOHMA1 || i == eGOHMA2 ||
13805 i == eGOHMA3 || i == eGOHMA4)
13806 {
13807 if(tempguy.weapon == ewFireball)
13808 tempguy.weapon = ewFireball2;
13809 }
13810 }
13811
13812
1/2
✓ Branch 0 taken 57344 times.
✗ Branch 1 not taken.
57344 if(!p_igetw(&(tempguy.rate),f))
13813 {
13814 return qe_invalid;
13815 }
13816
13817
1/2
✓ Branch 0 taken 57344 times.
✗ Branch 1 not taken.
57344 if(!p_igetw(&(tempguy.hrate),f))
13818 {
13819 return qe_invalid;
13820 }
13821
13822
1/2
✓ Branch 0 taken 57344 times.
✗ Branch 1 not taken.
57344 if(!p_igetw(&(tempguy.step),f))
13823 {
13824 return qe_invalid;
13825 }
13826
13827 // HIGHLY UNORTHODOX UPDATING THING, part 2
13828
3/4
✓ Branch 0 taken 1536 times.
✓ Branch 1 taken 55808 times.
✓ Branch 2 taken 1536 times.
✗ Branch 3 not taken.
57344 if(fixpolsvoice && tempguy.family==eePOLSV)
13829 {
13830 tempguy.step /= 2;
13831 }
13832
13833
1/2
✓ Branch 0 taken 57344 times.
✗ Branch 1 not taken.
57344 if(!p_igetw(&(tempguy.homing),f))
13834 {
13835 return qe_invalid;
13836 }
13837
13838
1/2
✓ Branch 0 taken 57344 times.
✗ Branch 1 not taken.
57344 if(!p_igetw(&(tempguy.grumble),f))
13839 {
13840 return qe_invalid;
13841 }
13842
13843
1/2
✓ Branch 0 taken 57344 times.
✗ Branch 1 not taken.
57344 if(!p_igetw(&(tempguy.item_set),f))
13844 {
13845 return qe_invalid;
13846 }
13847
13848
1/2
✓ Branch 0 taken 57344 times.
✗ Branch 1 not taken.
57344 if(guyversion>=22) // Version 22: Expand misc attributes to 32 bits
13849 {
13850
1/2
✓ Branch 0 taken 57344 times.
✗ Branch 1 not taken.
57344 if(!p_igetl(&(tempguy.misc1),f))
13851 {
13852 return qe_invalid;
13853 }
13854
13855
1/2
✓ Branch 0 taken 57344 times.
✗ Branch 1 not taken.
57344 if(!p_igetl(&(tempguy.misc2),f))
13856 {
13857 return qe_invalid;
13858 }
13859
13860
1/2
✓ Branch 0 taken 57344 times.
✗ Branch 1 not taken.
57344 if(!p_igetl(&(tempguy.misc3),f))
13861 {
13862 return qe_invalid;
13863 }
13864
13865
1/2
✓ Branch 0 taken 57344 times.
✗ Branch 1 not taken.
57344 if(!p_igetl(&(tempguy.misc4),f))
13866 {
13867 return qe_invalid;
13868 }
13869
13870
1/2
✓ Branch 0 taken 57344 times.
✗ Branch 1 not taken.
57344 if(!p_igetl(&(tempguy.misc5),f))
13871 {
13872 return qe_invalid;
13873 }
13874
13875
1/2
✓ Branch 0 taken 57344 times.
✗ Branch 1 not taken.
57344 if(!p_igetl(&(tempguy.misc6),f))
13876 {
13877 return qe_invalid;
13878 }
13879
13880
1/2
✓ Branch 0 taken 57344 times.
✗ Branch 1 not taken.
57344 if(!p_igetl(&(tempguy.misc7),f))
13881 {
13882 return qe_invalid;
13883 }
13884
13885
1/2
✓ Branch 0 taken 57344 times.
✗ Branch 1 not taken.
57344 if(!p_igetl(&(tempguy.misc8),f))
13886 {
13887 return qe_invalid;
13888 }
13889
13890
1/2
✓ Branch 0 taken 57344 times.
✗ Branch 1 not taken.
57344 if(!p_igetl(&(tempguy.misc9),f))
13891 {
13892 return qe_invalid;
13893 }
13894
13895
1/2
✓ Branch 0 taken 57344 times.
✗ Branch 1 not taken.
57344 if(!p_igetl(&(tempguy.misc10),f))
13896 {
13897 return qe_invalid;
13898 }
13899 57344 }
13900 else
13901 {
13902 int16_t tempMisc;
13903
13904 if(!p_igetw(&tempMisc,f))
13905 {
13906 return qe_invalid;
13907 }
13908
13909 tempguy.misc1=tempMisc;
13910
13911 if(!p_igetw(&tempMisc,f))
13912 {
13913 return qe_invalid;
13914 }
13915
13916 tempguy.misc2=tempMisc;
13917
13918 if(!p_igetw(&tempMisc,f))
13919 {
13920 return qe_invalid;
13921 }
13922
13923 tempguy.misc3=tempMisc;
13924
13925 if(!p_igetw(&tempMisc,f))
13926 {
13927 return qe_invalid;
13928 }
13929
13930 tempguy.misc4=tempMisc;
13931
13932 if(!p_igetw(&tempMisc,f))
13933 {
13934 return qe_invalid;
13935 }
13936
13937 tempguy.misc5=tempMisc;
13938
13939 if(guyversion < 13) // April 2009 - a tiny Wizzrobe update
13940 {
13941 if(tempguy.family == eeWIZZ && !(tempguy.misc1))
13942 tempguy.misc5 = 74;
13943 }
13944
13945 if(!p_igetw(&tempMisc,f))
13946 {
13947 return qe_invalid;
13948 }
13949
13950 tempguy.misc6=tempMisc;
13951
13952 if(!p_igetw(&tempMisc,f))
13953 {
13954 return qe_invalid;
13955 }
13956
13957 tempguy.misc7=tempMisc;
13958
13959 if(!p_igetw(&tempMisc,f))
13960 {
13961 return qe_invalid;
13962 }
13963
13964 tempguy.misc8=tempMisc;
13965
13966 if(!p_igetw(&tempMisc,f))
13967 {
13968 return qe_invalid;
13969 }
13970
13971 tempguy.misc9=tempMisc;
13972
13973 if(!p_igetw(&tempMisc,f))
13974 {
13975 return qe_invalid;
13976 }
13977
13978 tempguy.misc10=tempMisc;
13979 }
13980
13981
1/2
✓ Branch 0 taken 57344 times.
✗ Branch 1 not taken.
57344 if(!p_igetw(&(tempguy.bgsfx),f))
13982 {
13983 return qe_invalid;
13984 }
13985
13986
1/2
✓ Branch 0 taken 57344 times.
✗ Branch 1 not taken.
57344 if(!p_igetw(&(tempguy.bosspal),f))
13987 {
13988 return qe_invalid;
13989 }
13990
13991
1/2
✓ Branch 0 taken 57344 times.
✗ Branch 1 not taken.
57344 if(!p_igetw(&(tempguy.extend),f))
13992 {
13993 return qe_invalid;
13994 }
13995
13996 //! Enemy Defences
13997
13998 //If a 2.50 quest, use only the 2.5 defences.
13999
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 57344 times.
57344 if(guyversion >= 16 ) // November 2009 - Super Enemy Editor
14000 {
14001
2/2
✓ Branch 0 taken 1089536 times.
✓ Branch 1 taken 57344 times.
1146880 for(int32_t j=0; j<edefLAST; j++)
14002 {
14003
1/2
✓ Branch 0 taken 1089536 times.
✗ Branch 1 not taken.
1089536 if(!p_getc(&(tempguy.defense[j]),f))
14004 {
14005 return qe_invalid;
14006 }
14007 1089536 }
14008 //then copy the generic script defence to all the new script defences
14009
14010 57344 }
14011
14012
14013
14014
14015
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 57344 times.
57344 if(guyversion >= 18)
14016 {
14017
1/2
✓ Branch 0 taken 57344 times.
✗ Branch 1 not taken.
57344 if(!p_getc(&(tempguy.hitsfx),f))
14018 {
14019 return qe_invalid;
14020 }
14021
14022
1/2
✓ Branch 0 taken 57344 times.
✗ Branch 1 not taken.
57344 if(!p_getc(&(tempguy.deadsfx),f))
14023 {
14024 return qe_invalid;
14025 }
14026 57344 }
14027
14028
1/2
✓ Branch 0 taken 57344 times.
✗ Branch 1 not taken.
57344 if(guyversion >= 22)
14029 {
14030
1/2
✓ Branch 0 taken 57344 times.
✗ Branch 1 not taken.
57344 if(!p_igetl(&(tempguy.misc11),f))
14031 {
14032 return qe_invalid;
14033 }
14034
14035
1/2
✓ Branch 0 taken 57344 times.
✗ Branch 1 not taken.
57344 if(!p_igetl(&(tempguy.misc12),f))
14036 {
14037 return qe_invalid;
14038 }
14039 57344 }
14040 else if(guyversion >= 19)
14041 {
14042 int16_t tempMisc;
14043
14044 if(!p_igetw(&tempMisc,f))
14045 {
14046 return qe_invalid;
14047 }
14048
14049 tempguy.misc11=tempMisc;
14050
14051 if(!p_igetw(&tempMisc,f))
14052 {
14053 return qe_invalid;
14054 }
14055
14056 tempguy.misc12=tempMisc;
14057 }
14058
14059 //If a 2.54 or later quest, use all of the defences.
14060
2/2
✓ Branch 0 taken 39424 times.
✓ Branch 1 taken 17920 times.
57344 if(guyversion > 24) // Add new guyversion conditional statement
14061 {
14062
2/2
✓ Branch 0 taken 394240 times.
✓ Branch 1 taken 17920 times.
412160 for(int32_t j=edefLAST; j<edefLAST255; j++)
14063 {
14064
1/2
✓ Branch 0 taken 394240 times.
✗ Branch 1 not taken.
394240 if(!p_getc(&(tempguy.defense[j]),f))
14065 {
14066 return qe_invalid;
14067 }
14068 394240 }
14069 17920 }
14070
14071
2/2
✓ Branch 0 taken 17920 times.
✓ Branch 1 taken 39424 times.
57344 if(guyversion <= 24) // Port over generic script settings from old quests in the new editor.
14072 {
14073
2/2
✓ Branch 0 taken 394240 times.
✓ Branch 1 taken 39424 times.
433664 for(int32_t j=edefSCRIPT01; j<=edefSCRIPT10; j++)
14074 {
14075 394240 tempguy.defense[j] = tempguy.defense[edefSCRIPT] ;
14076 394240 }
14077 39424 }
14078
14079 //tilewidth, tileheight, hitwidth, hitheight, hitzheight, hitxofs, hityofs, hitzofs
14080
2/2
✓ Branch 0 taken 39424 times.
✓ Branch 1 taken 17920 times.
57344 if(guyversion > 25)
14081 {
14082
1/2
✓ Branch 0 taken 17920 times.
✗ Branch 1 not taken.
17920 if(!p_igetl(&(tempguy.txsz),f))
14083 {
14084 return qe_invalid;
14085 }
14086
1/2
✓ Branch 0 taken 17920 times.
✗ Branch 1 not taken.
17920 if(!p_igetl(&(tempguy.tysz),f))
14087 {
14088 return qe_invalid;
14089 }
14090
1/2
✓ Branch 0 taken 17920 times.
✗ Branch 1 not taken.
17920 if(!p_igetl(&(tempguy.hxsz),f))
14091 {
14092 return qe_invalid;
14093 }
14094
1/2
✓ Branch 0 taken 17920 times.
✗ Branch 1 not taken.
17920 if(!p_igetl(&(tempguy.hysz),f))
14095 {
14096 return qe_invalid;
14097 }
14098
1/2
✓ Branch 0 taken 17920 times.
✗ Branch 1 not taken.
17920 if(!p_igetl(&(tempguy.hzsz),f))
14099 {
14100 return qe_invalid;
14101 }
14102 /* Is it safe to read a fixed with getl, or do I need to typecast it? -Z
14103
14104 */
14105 17920 }
14106 //More Enemy Editor vars for 2.60
14107
2/2
✓ Branch 0 taken 39424 times.
✓ Branch 1 taken 17920 times.
57344 if(guyversion > 26)
14108 {
14109
1/2
✓ Branch 0 taken 17920 times.
✗ Branch 1 not taken.
17920 if(!p_igetl(&(tempguy.hxofs),f))
14110 {
14111 return qe_invalid;
14112 }
14113
1/2
✓ Branch 0 taken 17920 times.
✗ Branch 1 not taken.
17920 if(!p_igetl(&(tempguy.hyofs),f))
14114 {
14115 return qe_invalid;
14116 }
14117
1/2
✓ Branch 0 taken 17920 times.
✗ Branch 1 not taken.
17920 if(!p_igetl(&(tempguy.xofs),f))
14118 {
14119 return qe_invalid;
14120 }
14121
1/2
✓ Branch 0 taken 17920 times.
✗ Branch 1 not taken.
17920 if(!p_igetl(&(tempguy.yofs),f))
14122 {
14123 return qe_invalid;
14124 }
14125
1/2
✓ Branch 0 taken 17920 times.
✗ Branch 1 not taken.
17920 if(!p_igetl(&(tempguy.zofs),f))
14126 {
14127 return qe_invalid;
14128 }
14129 17920 }
14130
14131
2/2
✓ Branch 0 taken 17920 times.
✓ Branch 1 taken 39424 times.
57344 if(guyversion <= 27) // Port over generic script settings from old quests in the new editor.
14132 {
14133 39424 tempguy.wpnsprite = 0;
14134 39424 }
14135
14136
2/2
✓ Branch 0 taken 39424 times.
✓ Branch 1 taken 17920 times.
57344 if(guyversion > 27)
14137 {
14138
1/2
✓ Branch 0 taken 17920 times.
✗ Branch 1 not taken.
17920 if(!p_igetl(&(tempguy.wpnsprite),f))
14139 {
14140 return qe_invalid;
14141 }
14142 17920 }
14143
2/2
✓ Branch 0 taken 17920 times.
✓ Branch 1 taken 39424 times.
57344 if(guyversion <= 28) // Port over generic script settings from old quests in the new editor.
14144 {
14145 39424 tempguy.SIZEflags = 0;
14146 39424 }
14147
2/2
✓ Branch 0 taken 39424 times.
✓ Branch 1 taken 17920 times.
57344 if(guyversion > 28)
14148 {
14149
1/2
✓ Branch 0 taken 17920 times.
✗ Branch 1 not taken.
17920 if(!p_igetl(&(tempguy.SIZEflags),f))
14150 {
14151 return qe_invalid;
14152 }
14153
14154 17920 }
14155
2/2
✓ Branch 0 taken 17920 times.
✓ Branch 1 taken 39424 times.
57344 if(guyversion < 30) // Port over generic script settings from old quests in the new editor.
14156 {
14157 39424 tempguy.frozentile = 0;
14158 39424 tempguy.frozencset = 0;
14159 39424 tempguy.frozenclock = 0;
14160
2/2
✓ Branch 0 taken 394240 times.
✓ Branch 1 taken 39424 times.
433664 for ( int32_t q = 0; q < 10; q++ ) tempguy.frozenmisc[q] = 0;
14161 39424 }
14162
2/2
✓ Branch 0 taken 39424 times.
✓ Branch 1 taken 17920 times.
57344 if(guyversion >= 30)
14163 {
14164
1/2
✓ Branch 0 taken 17920 times.
✗ Branch 1 not taken.
17920 if(!p_igetl(&(tempguy.frozentile),f))
14165 {
14166 return qe_invalid;
14167 }
14168
1/2
✓ Branch 0 taken 17920 times.
✗ Branch 1 not taken.
17920 if(!p_igetl(&(tempguy.frozencset),f))
14169 {
14170 return qe_invalid;
14171 }
14172
1/2
✓ Branch 0 taken 17920 times.
✗ Branch 1 not taken.
17920 if(!p_igetl(&(tempguy.frozenclock),f))
14173 {
14174 return qe_invalid;
14175 }
14176
2/2
✓ Branch 0 taken 179200 times.
✓ Branch 1 taken 17920 times.
197120 for ( int32_t q = 0; q < 10; q++ ) {
14177
1/2
✓ Branch 0 taken 179200 times.
✗ Branch 1 not taken.
179200 if(!p_igetw(&(tempguy.frozenmisc[q]),f))
14178 {
14179 return qe_invalid;
14180 }
14181 179200 }
14182
14183 17920 }
14184
14185
2/2
✓ Branch 0 taken 39424 times.
✓ Branch 1 taken 17920 times.
57344 if(guyversion >= 34)
14186 {
14187
1/2
✓ Branch 0 taken 17920 times.
✗ Branch 1 not taken.
17920 if(!p_igetw(&(tempguy.firesfx),f))
14188 {
14189 return qe_invalid;
14190 }
14191
1/2
✓ Branch 0 taken 17920 times.
✗ Branch 1 not taken.
17920 if(!p_igetl(&(tempguy.misc16),f))
14192 {
14193 return qe_invalid;
14194 }
14195
1/2
✓ Branch 0 taken 17920 times.
✗ Branch 1 not taken.
17920 if(!p_igetl(&(tempguy.misc17),f))
14196 {
14197 return qe_invalid;
14198 }
14199
1/2
✓ Branch 0 taken 17920 times.
✗ Branch 1 not taken.
17920 if(!p_igetl(&(tempguy.misc18),f))
14200 {
14201 return qe_invalid;
14202 }
14203
1/2
✓ Branch 0 taken 17920 times.
✗ Branch 1 not taken.
17920 if(!p_igetl(&(tempguy.misc19),f))
14204 {
14205 return qe_invalid;
14206 }
14207
1/2
✓ Branch 0 taken 17920 times.
✗ Branch 1 not taken.
17920 if(!p_igetl(&(tempguy.misc20),f))
14208 {
14209 return qe_invalid;
14210 }
14211
1/2
✓ Branch 0 taken 17920 times.
✗ Branch 1 not taken.
17920 if(!p_igetl(&(tempguy.misc21),f))
14212 {
14213 return qe_invalid;
14214 }
14215
1/2
✓ Branch 0 taken 17920 times.
✗ Branch 1 not taken.
17920 if(!p_igetl(&(tempguy.misc22),f))
14216 {
14217 return qe_invalid;
14218 }
14219
1/2
✓ Branch 0 taken 17920 times.
✗ Branch 1 not taken.
17920 if(!p_igetl(&(tempguy.misc23),f))
14220 {
14221 return qe_invalid;
14222 }
14223
1/2
✓ Branch 0 taken 17920 times.
✗ Branch 1 not taken.
17920 if(!p_igetl(&(tempguy.misc24),f))
14224 {
14225 return qe_invalid;
14226 }
14227
1/2
✓ Branch 0 taken 17920 times.
✗ Branch 1 not taken.
17920 if(!p_igetl(&(tempguy.misc25),f))
14228 {
14229 return qe_invalid;
14230 }
14231
1/2
✓ Branch 0 taken 17920 times.
✗ Branch 1 not taken.
17920 if(!p_igetl(&(tempguy.misc26),f))
14232 {
14233 return qe_invalid;
14234 }
14235
1/2
✓ Branch 0 taken 17920 times.
✗ Branch 1 not taken.
17920 if(!p_igetl(&(tempguy.misc27),f))
14236 {
14237 return qe_invalid;
14238 }
14239
1/2
✓ Branch 0 taken 17920 times.
✗ Branch 1 not taken.
17920 if(!p_igetl(&(tempguy.misc28),f))
14240 {
14241 return qe_invalid;
14242 }
14243
1/2
✓ Branch 0 taken 17920 times.
✗ Branch 1 not taken.
17920 if(!p_igetl(&(tempguy.misc29),f))
14244 {
14245 return qe_invalid;
14246 }
14247
1/2
✓ Branch 0 taken 17920 times.
✗ Branch 1 not taken.
17920 if(!p_igetl(&(tempguy.misc30),f))
14248 {
14249 return qe_invalid;
14250 }
14251
1/2
✓ Branch 0 taken 17920 times.
✗ Branch 1 not taken.
17920 if(!p_igetl(&(tempguy.misc31),f))
14252 {
14253 return qe_invalid;
14254 }
14255
1/2
✓ Branch 0 taken 17920 times.
✗ Branch 1 not taken.
17920 if(!p_igetl(&(tempguy.misc32),f))
14256 {
14257 return qe_invalid;
14258 }
14259
14260
2/2
✓ Branch 0 taken 573440 times.
✓ Branch 1 taken 17920 times.
591360 for ( int32_t q = 0; q < 32; q++ ) {
14261
1/2
✓ Branch 0 taken 573440 times.
✗ Branch 1 not taken.
573440 if(!p_igetl(&(tempguy.movement[q]),f))
14262 {
14263 return qe_invalid;
14264 }
14265 573440 }
14266
2/2
✓ Branch 0 taken 573440 times.
✓ Branch 1 taken 17920 times.
591360 for ( int32_t q = 0; q < 32; q++ ) {
14267
1/2
✓ Branch 0 taken 573440 times.
✗ Branch 1 not taken.
573440 if(!p_igetl(&(tempguy.new_weapon[q]),f))
14268 {
14269 return qe_invalid;
14270 }
14271 573440 }
14272
1/2
✓ Branch 0 taken 17920 times.
✗ Branch 1 not taken.
17920 if(!p_igetw(&(tempguy.script),f))
14273 {
14274 return qe_invalid;
14275 }
14276 //al_trace("NPC Script ID is: %d\n",tempguy.script);
14277
2/2
✓ Branch 0 taken 143360 times.
✓ Branch 1 taken 17920 times.
161280 for ( int32_t q = 0; q < 8; q++ )
14278 {
14279
1/2
✓ Branch 0 taken 143360 times.
✗ Branch 1 not taken.
143360 if(!p_igetl(&(tempguy.initD[q]),f))
14280 {
14281 return qe_invalid;
14282 }
14283 143360 }
14284
2/2
✓ Branch 0 taken 35840 times.
✓ Branch 1 taken 17920 times.
53760 for ( int32_t q = 0; q < 2; q++ )
14285 {
14286
1/2
✓ Branch 0 taken 35840 times.
✗ Branch 1 not taken.
35840 if(!p_igetl(&(tempguy.initA[q]),f))
14287 {
14288 return qe_invalid;
14289 }
14290 35840 }
14291
14292 17920 }
14293
14294
2/2
✓ Branch 0 taken 39424 times.
✓ Branch 1 taken 17920 times.
57344 if(guyversion >= 37)
14295 {
14296
1/2
✓ Branch 0 taken 17920 times.
✗ Branch 1 not taken.
17920 if(!p_igetl(&(tempguy.editorflags),f))
14297 {
14298 return qe_invalid;
14299 }
14300 17920 }
14301
2/2
✓ Branch 0 taken 17920 times.
✓ Branch 1 taken 39424 times.
57344 if ( guyversion < 37 ) { tempguy.editorflags = 0; }
14302
2/2
✓ Branch 0 taken 39424 times.
✓ Branch 1 taken 17920 times.
57344 if(guyversion >= 38)
14303 {
14304
1/2
✓ Branch 0 taken 17920 times.
✗ Branch 1 not taken.
17920 if(!p_igetl(&(tempguy.misc13),f))
14305 {
14306 return qe_invalid;
14307 }
14308
1/2
✓ Branch 0 taken 17920 times.
✗ Branch 1 not taken.
17920 if(!p_igetl(&(tempguy.misc14),f))
14309 {
14310 return qe_invalid;
14311 }
14312
1/2
✓ Branch 0 taken 17920 times.
✗ Branch 1 not taken.
17920 if(!p_igetl(&(tempguy.misc15),f))
14313 {
14314 return qe_invalid;
14315 }
14316
14317 17920 }
14318
2/2
✓ Branch 0 taken 17920 times.
✓ Branch 1 taken 39424 times.
57344 if ( guyversion < 38 )
14319 {
14320 39424 tempguy.misc13 = 0;
14321 39424 tempguy.misc14 = 0;
14322 39424 tempguy.misc15 = 0;
14323 39424 }
14324
14325
2/2
✓ Branch 0 taken 39424 times.
✓ Branch 1 taken 17920 times.
57344 if ( guyversion >= 39 )
14326 {
14327
2/2
✓ Branch 0 taken 143360 times.
✓ Branch 1 taken 17920 times.
161280 for ( int32_t q = 0; q < 8; q++ )
14328 {
14329
2/2
✓ Branch 0 taken 9318400 times.
✓ Branch 1 taken 143360 times.
9461760 for ( int32_t w = 0; w < 65; w++ )
14330 {
14331
1/2
✓ Branch 0 taken 9318400 times.
✗ Branch 1 not taken.
9318400 if(!p_getc(&(tempguy.initD_label[q][w]),f))
14332 {
14333 return qe_invalid;
14334 }
14335 9318400 }
14336
2/2
✓ Branch 0 taken 9318400 times.
✓ Branch 1 taken 143360 times.
9461760 for ( int32_t w = 0; w < 65; w++ )
14337 {
14338
1/2
✓ Branch 0 taken 9318400 times.
✗ Branch 1 not taken.
9318400 if(!p_getc(&(tempguy.weapon_initD_label[q][w]),f))
14339 {
14340 return qe_invalid;
14341 }
14342 9318400 }
14343 143360 }
14344
14345
14346 17920 }
14347
2/2
✓ Branch 0 taken 17920 times.
✓ Branch 1 taken 39424 times.
57344 if ( guyversion < 39 ) //apply old InitD strings to both
14348 {
14349
2/2
✓ Branch 0 taken 315392 times.
✓ Branch 1 taken 39424 times.
354816 for ( int32_t q = 0; q < 8; q++ )
14350 {
14351 315392 sprintf(tempguy.initD_label[q],"InitD[%d]",q);
14352 315392 sprintf(tempguy.weapon_initD_label[q],"InitD[%d]",q);
14353 315392 }
14354 39424 }
14355
2/2
✓ Branch 0 taken 39424 times.
✓ Branch 1 taken 17920 times.
57344 if ( guyversion >= 40 )
14356 {
14357
1/2
✓ Branch 0 taken 17920 times.
✗ Branch 1 not taken.
17920 if(!p_igetw(&(tempguy.weaponscript),f))
14358 {
14359 return qe_invalid;
14360 }
14361 17920 }
14362
2/2
✓ Branch 0 taken 17920 times.
✓ Branch 1 taken 39424 times.
57344 if ( guyversion < 40 )
14363 {
14364 39424 tempguy.weaponscript = 0;
14365 39424 }
14366 //eweapon script InitD
14367
2/2
✓ Branch 0 taken 39424 times.
✓ Branch 1 taken 17920 times.
57344 if ( guyversion >= 41 )
14368 {
14369
2/2
✓ Branch 0 taken 143360 times.
✓ Branch 1 taken 17920 times.
161280 for ( int32_t q = 0; q < 8; q++ )
14370 {
14371
1/2
✓ Branch 0 taken 143360 times.
✗ Branch 1 not taken.
143360 if(!p_igetl(&(tempguy.weap_initiald[q]),f))
14372 {
14373 return qe_invalid;
14374 }
14375 143360 }
14376
1/2
✓ Branch 0 taken 17920 times.
✗ Branch 1 not taken.
17920 if ( guy_cversion < 4 )
14377 {
14378 if ( tempguy.family == eeKEESE )
14379 {
14380
14381 if ( !tempguy.misc1 )
14382 {
14383 tempguy.misc16 = 120;
14384 tempguy.misc17 = 16;
14385
14386 }
14387 }
14388 if ( tempguy.family == eePEAHAT )
14389 {
14390 tempguy.misc16 = 80;
14391 tempguy.misc17 = 16;
14392 }
14393
14394 if ( tempguy.family == eeGHINI )
14395 {
14396 tempguy.misc16 = 120;
14397 tempguy.misc17 = 10;
14398 }
14399
14400 }
14401 17920 }
14402
14403
14404
14405 //default weapon sprites (quest version < 2.54)
14406 //port over old defaults -Z
14407
2/2
✓ Branch 0 taken 17920 times.
✓ Branch 1 taken 39424 times.
57344 if(guyversion < 32)
14408 {
14409
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 39424 times.
39424 if ( tempguy.wpnsprite <= 0 )
14410 {
14411
16/20
✗ Branch 0 not taken.
✓ Branch 1 taken 1303 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 32842 times.
✓ Branch 4 taken 302 times.
✓ Branch 5 taken 314 times.
✓ Branch 6 taken 931 times.
✓ Branch 7 taken 493 times.
✓ Branch 8 taken 912 times.
✓ Branch 9 taken 80 times.
✓ Branch 10 taken 18 times.
✓ Branch 11 taken 137 times.
✓ Branch 12 taken 19 times.
✓ Branch 13 taken 363 times.
✓ Branch 14 taken 759 times.
✓ Branch 15 taken 106 times.
✓ Branch 16 taken 80 times.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✓ Branch 19 taken 765 times.
39424 switch(tempguy.weapon)
14412 {
14413 case wNone:
14414 32842 tempguy.wpnsprite = 0; break;
14415
14416 case wSword:
14417 case wBeam:
14418 case wBrang:
14419 case wBomb:
14420 case wSBomb:
14421 case wLitBomb:
14422 case wLitSBomb:
14423 case wArrow:
14424 case wFire:
14425 case wWhistle:
14426 case wBait:
14427 case wWand:
14428 case wMagic:
14429 case wCatching:
14430 case wWind:
14431 case wRefMagic:
14432 case wRefFireball:
14433 case wRefRock:
14434 case wHammer:
14435 case wHookshot:
14436 case wHSHandle:
14437 case wHSChain:
14438 case wSSparkle:
14439 case wFSparkle:
14440 case wSmack:
14441 case wPhantom:
14442 case wCByrna:
14443 case wRefBeam:
14444 case wStomp:
14445 case lwMax:
14446 case wScript1:
14447 case wScript2:
14448 case wScript3:
14449 case wScript4:
14450 case wScript5:
14451 case wScript6:
14452 case wScript7:
14453 case wScript8:
14454 case wScript9:
14455 case wScript10:
14456 case wIce:
14457 //Cannot use any of these weapons yet.
14458 tempguy.wpnsprite = -1;
14459 break;
14460
14461 case wEnemyWeapons:
14462 1303 case ewFireball: tempguy.wpnsprite = 17; break;
14463
14464 302 case ewArrow: tempguy.wpnsprite = 19; break;
14465 314 case ewBrang: tempguy.wpnsprite = 4; break;
14466 931 case ewSword: tempguy.wpnsprite = 20; break;
14467 493 case ewRock: tempguy.wpnsprite = 18; break;
14468 912 case ewMagic: tempguy.wpnsprite = 21; break;
14469 80 case ewBomb: tempguy.wpnsprite = 78; break;
14470 18 case ewSBomb: tempguy.wpnsprite = 79; break;
14471 137 case ewLitBomb: tempguy.wpnsprite = 76; break;
14472 19 case ewLitSBomb: tempguy.wpnsprite = 77; break;
14473 363 case ewFireTrail: tempguy.wpnsprite = 80; break;
14474 759 case ewFlame: tempguy.wpnsprite = 35; break;
14475 106 case ewWind: tempguy.wpnsprite = 36; break;
14476 80 case ewFlame2: tempguy.wpnsprite = 81; break;
14477 case ewFlame2Trail: tempguy.wpnsprite = 82; break;
14478 case ewIce: tempguy.wpnsprite = 83; break;
14479 765 case ewFireball2: tempguy.wpnsprite = 17; break; //fireball (rising)
14480
14481
14482 default: break; //No assign.
14483 }
14484 39424 }
14485 39424 }
14486
14487 //default weapon fire sound (quest version < 2.54)
14488 //port over old defaults and zero new data. -Z
14489
2/2
✓ Branch 0 taken 17920 times.
✓ Branch 1 taken 39424 times.
57344 if(guyversion < 34)
14490 {
14491
2/2
✓ Branch 0 taken 1261568 times.
✓ Branch 1 taken 39424 times.
1300992 for ( int32_t q = 0; q < 32; q++ )
14492 {
14493 1261568 tempguy.movement[q] = 0;
14494 1261568 tempguy.new_weapon[q] = 0;
14495
14496 1261568 }
14497
14498 //NPC Script attributes.
14499 39424 tempguy.script = 0; //No scripted enemies existed. -Z
14500
2/2
✓ Branch 0 taken 315392 times.
✓ Branch 1 taken 39424 times.
354816 for ( int32_t q = 0; q < 8; q++ ) tempguy.initD[q] = 0; //Script Data
14501
2/2
✓ Branch 0 taken 78848 times.
✓ Branch 1 taken 39424 times.
118272 for ( int32_t q = 0; q < 2; q++ ) tempguy.initA[q] = 0; //Script Data
14502
14503 39424 tempguy.misc16 = 0;
14504 39424 tempguy.misc17 = 0;
14505 39424 tempguy.misc18 = 0;
14506 39424 tempguy.misc19 = 0;
14507 39424 tempguy.misc20 = 0;
14508 39424 tempguy.misc21 = 0;
14509 39424 tempguy.misc22 = 0;
14510 39424 tempguy.misc23 = 0;
14511 39424 tempguy.misc24 = 0;
14512 39424 tempguy.misc25 = 0;
14513 39424 tempguy.misc26 = 0;
14514 39424 tempguy.misc27 = 0;
14515 39424 tempguy.misc28 = 0;
14516 39424 tempguy.misc29 = 0;
14517 39424 tempguy.misc30 = 0;
14518 39424 tempguy.misc31 = 0;
14519 39424 tempguy.misc32 = 0;
14520
14521 //old default sounds
14522
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 39424 times.
39424 if ( tempguy.firesfx <= 0 )
14523 {
14524
16/20
✗ Branch 0 not taken.
✓ Branch 1 taken 1303 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 32842 times.
✓ Branch 4 taken 302 times.
✓ Branch 5 taken 314 times.
✓ Branch 6 taken 931 times.
✓ Branch 7 taken 493 times.
✓ Branch 8 taken 912 times.
✓ Branch 9 taken 80 times.
✓ Branch 10 taken 18 times.
✓ Branch 11 taken 137 times.
✓ Branch 12 taken 19 times.
✓ Branch 13 taken 363 times.
✓ Branch 14 taken 759 times.
✓ Branch 15 taken 106 times.
✓ Branch 16 taken 80 times.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✓ Branch 19 taken 765 times.
39424 switch(tempguy.weapon)
14525 {
14526 case wNone:
14527 32842 tempguy.firesfx = 0; break;
14528
14529 case wSword:
14530 case wBeam:
14531 case wBrang:
14532 case wBomb:
14533 case wSBomb:
14534 case wLitBomb:
14535 case wLitSBomb:
14536 case wArrow:
14537 case wFire:
14538 case wWhistle:
14539 case wBait:
14540 case wWand:
14541 case wMagic:
14542 case wCatching:
14543 case wWind:
14544 case wRefMagic:
14545 case wRefFireball:
14546 case wRefRock:
14547 case wHammer:
14548 case wHookshot:
14549 case wHSHandle:
14550 case wHSChain:
14551 case wSSparkle:
14552 case wFSparkle:
14553 case wSmack:
14554 case wPhantom:
14555 case wCByrna:
14556 case wRefBeam:
14557 case wStomp:
14558 case lwMax:
14559 case wScript1:
14560 case wScript2:
14561 case wScript3:
14562 case wScript4:
14563 case wScript5:
14564 case wScript6:
14565 case wScript7:
14566 case wScript8:
14567 case wScript9:
14568 case wScript10:
14569 case wIce:
14570 //Cannot use any of these weapons yet.
14571 tempguy.firesfx = -1;
14572 break;
14573
14574 case wEnemyWeapons:
14575 1303 case ewFireball: tempguy.firesfx = 40; break;
14576
14577 302 case ewArrow: tempguy.firesfx = 1; break; //Ghost.zh has 0?
14578 314 case ewBrang: tempguy.firesfx = 4; break; //Ghost.zh has 0?
14579 931 case ewSword: tempguy.firesfx = 20; break; //Ghost.zh has 0?
14580 493 case ewRock: tempguy.firesfx = 51; break;
14581 912 case ewMagic: tempguy.firesfx = 32; break;
14582 80 case ewBomb: tempguy.firesfx = 3; break; //Ghost.zh has 0?
14583 18 case ewSBomb: tempguy.firesfx = 3; break; //Ghost.zh has 0?
14584 137 case ewLitBomb: tempguy.firesfx = 21; break; //Ghost.zh has 0?
14585 19 case ewLitSBomb: tempguy.firesfx = 21; break; //Ghost.zh has 0?
14586 363 case ewFireTrail: tempguy.firesfx = 13; break;
14587 759 case ewFlame: tempguy.firesfx = 13; break;
14588 106 case ewWind: tempguy.firesfx = 32; break;
14589 80 case ewFlame2: tempguy.firesfx = 13; break;
14590 case ewFlame2Trail: tempguy.firesfx = 13; break;
14591 case ewIce: tempguy.firesfx = 44; break;
14592 765 case ewFireball2: tempguy.firesfx = 40; break; //fireball (rising)
14593
14594 //what about special attacks (e.g. summoning == 56)
14595 default: break; //No assign.
14596 }
14597 39424 }
14598 39424 }
14599
14600 //Port hardcoded hit sound to the enemy hitsfx defaults for older quests.
14601
4/6
✓ Branch 0 taken 17920 times.
✓ Branch 1 taken 39424 times.
✓ Branch 2 taken 17920 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 17920 times.
57344 if(Header->zelda_version <= 0x250 || ( Header->zelda_version > 0x250 && guyversion < 35 ))
14602 {
14603
2/2
✓ Branch 0 taken 3549 times.
✓ Branch 1 taken 35875 times.
39424 if ( tempguy.hitsfx == 0 ) tempguy.hitsfx = 11;
14604 39424 }
14605 //Keese and bat halt rates.
14606
3/4
✓ Branch 0 taken 39424 times.
✓ Branch 1 taken 17920 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 39424 times.
57344 if ( guyversion < 42 && guy_cversion < 4 )
14607 {
14608
14609
2/2
✓ Branch 0 taken 38895 times.
✓ Branch 1 taken 529 times.
39424 if ( tempguy.family == eeKEESE )
14610 {
14611
14612
2/2
✓ Branch 0 taken 203 times.
✓ Branch 1 taken 326 times.
529 if ( !tempguy.misc1 )
14613 {
14614 326 tempguy.misc16 = 120;
14615 326 tempguy.misc17 = 16;
14616
14617 326 }
14618 529 }
14619
2/2
✓ Branch 0 taken 39257 times.
✓ Branch 1 taken 167 times.
39424 if ( tempguy.family == eePEAHAT )
14620 {
14621 167 tempguy.misc16 = 80;
14622 167 tempguy.misc17 = 16;
14623 167 }
14624
2/2
✓ Branch 0 taken 39347 times.
✓ Branch 1 taken 77 times.
39424 if ( tempguy.family == eeGHINI )
14625 {
14626 77 tempguy.misc16 = 120;
14627 77 tempguy.misc17 = 10;
14628 77 }
14629
14630
14631 39424 }
14632
14633
14634 //miscellaneous other corrections
14635 //fix the mirror wizzrobe -DD
14636
1/2
✓ Branch 0 taken 57344 times.
✗ Branch 1 not taken.
57344 if(guyversion < 7)
14637 {
14638 if(i == eMWIZ)
14639 {
14640 tempguy.misc2 = 0;
14641 tempguy.misc4 = 1;
14642 }
14643 }
14644
14645
1/2
✓ Branch 0 taken 57344 times.
✗ Branch 1 not taken.
57344 if(guyversion < 8)
14646 {
14647 if(i == eGLEEOK1 || i == eGLEEOK2 || i == eGLEEOK3 || i == eGLEEOK4 || i == eGLEEOK1F || i == eGLEEOK2F || i == eGLEEOK3F || i == eGLEEOK4F)
14648 {
14649 // Some of these are deliberately different to NewDefault/defdata.cpp, by the way. -L
14650 tempguy.misc5 = 4; //neck length in segments
14651 tempguy.misc6 = 8; //neck offset from first body tile
14652 tempguy.misc7 = 40; //offset for each subsequent neck tile from the first neck tile
14653 tempguy.misc8 = 168; //head offset from first body tile
14654 tempguy.misc9 = 228; //flying head offset from first body tile
14655
14656 if(i == eGLEEOK1F || i == eGLEEOK2F || i == eGLEEOK3F || i == eGLEEOK4F)
14657 {
14658 tempguy.misc6 += 10; //neck offset from first body tile
14659 tempguy.misc8 -= 12; //head offset from first body tile
14660 }
14661 }
14662 }
14663
14664
1/2
✓ Branch 0 taken 57344 times.
✗ Branch 1 not taken.
57344 if(guyversion < 10) // December 2007 - Dodongo CSet fix
14665 {
14666 if(get_bit(deprecated_rules,46) && tempguy.family==eeDONGO && tempguy.misc1==0)
14667 tempguy.bosspal = spDIG;
14668 }
14669
14670
1/2
✓ Branch 0 taken 57344 times.
✗ Branch 1 not taken.
57344 if(guyversion < 11) // December 2007 - Spinning Tile fix
14671 {
14672 if(tempguy.family==eeSPINTILE)
14673 {
14674 tempguy.flags |= guy_superman;
14675 tempguy.item_set = 0; // Don't drop items
14676 tempguy.step = 300;
14677 }
14678 }
14679
14680
1/2
✓ Branch 0 taken 57344 times.
✗ Branch 1 not taken.
57344 if(guyversion < 12) // October 2008 - Flashing Bubble, Rope 2, and Ghini 2 fix
14681 {
14682 if(get_bit(deprecated_rules, qr_NOROPE2FLASH_DEP))
14683 {
14684 if(tempguy.family==eeROPE)
14685 {
14686 tempguy.flags2 &= ~guy_flashing;
14687 }
14688 }
14689
14690 if(get_bit(deprecated_rules, qr_NOBUBBLEFLASH_DEP))
14691 {
14692 if(tempguy.family==eeBUBBLE)
14693 {
14694 tempguy.flags2 &= ~guy_flashing;
14695 }
14696 }
14697
14698 if((tempguy.family==eeGHINI)&&(tempguy.misc1))
14699 {
14700 if(get_bit(deprecated_rules, qr_GHINI2BLINK_DEP))
14701 {
14702 tempguy.flags2 |= guy_blinking;
14703 }
14704
14705 if(get_bit(deprecated_rules, qr_PHANTOMGHINI2_DEP))
14706 {
14707 tempguy.flags2 |= guy_transparent;
14708 }
14709 }
14710 }
14711
14712
1/2
✓ Branch 0 taken 57344 times.
✗ Branch 1 not taken.
57344 if(guyversion < 15) // July 2009 - Guy Fire and Fairy fix
14713 {
14714 if(i==gFIRE)
14715 {
14716 tempguy.e_anim = aFLIP;
14717 tempguy.e_frate = 24;
14718 }
14719
14720 if(i==gFAIRY)
14721 {
14722 tempguy.e_anim = a2FRM;
14723 tempguy.e_frate = 16;
14724 }
14725 }
14726
14727
1/2
✓ Branch 0 taken 57344 times.
✗ Branch 1 not taken.
57344 if(guyversion < 16) // November 2009 - Super Enemy Editor part 1
14728 {
14729 if(i==0) Z_message("Updating guys to version 16...\n");
14730
14731 update_guy_1(&tempguy);
14732
14733 if(i==eMPOLSV)
14734 {
14735 tempguy.defense[edefARROW] = edCHINK;
14736 tempguy.defense[edefMAGIC] = ed1HKO;
14737 tempguy.defense[edefREFMAGIC] = ed1HKO;
14738 }
14739 }
14740
14741
1/2
✓ Branch 0 taken 57344 times.
✗ Branch 1 not taken.
57344 if(guyversion < 17) // December 2009
14742 {
14743 if(tempguy.family==eePROJECTILE)
14744 {
14745 tempguy.misc1 = 0;
14746 }
14747 }
14748
14749
1/2
✓ Branch 0 taken 57344 times.
✗ Branch 1 not taken.
57344 if(guyversion < 18) // January 2010
14750 {
14751 bool boss = (tempguy.family == eeAQUA || tempguy.family==eeDONGO || tempguy.family == eeMANHAN || tempguy.family == eeGHOMA || tempguy.family==eeDIG
14752 || tempguy.family == eeGLEEOK || tempguy.family==eePATRA || tempguy.family == eeGANON || tempguy.family==eeMOLD);
14753
14754 tempguy.hitsfx = (boss && tempguy.family != eeMOLD && tempguy.family != eeDONGO && tempguy.family != eeDIG) ? WAV_GASP : 0;
14755 tempguy.deadsfx = (boss && (tempguy.family != eeDIG || tempguy.misc10 == 0)) ? WAV_GASP : WAV_EDEAD;
14756
14757 if(tempguy.family == eeAQUA)
14758 for(int32_t j=0; j<edefLAST; j++) tempguy.defense[j] = default_guys[eRAQUAM].defense[j];
14759 else if(tempguy.family == eeMANHAN)
14760 for(int32_t j=0; j<edefLAST; j++) tempguy.defense[j] = default_guys[eMANHAN].defense[j];
14761 else if(tempguy.family==eePATRA)
14762 for(int32_t j=0; j<edefLAST; j++) tempguy.defense[j] = default_guys[eGLEEOK1].defense[j];
14763 else if(tempguy.family==eeGHOMA)
14764 {
14765 for(int32_t j=0; j<edefLAST; j++)
14766 tempguy.defense[j] = default_guys[eGOHMA1].defense[j];
14767
14768 tempguy.defense[edefARROW] = ((tempguy.misc1==3) ? edCHINKL8 : (tempguy.misc1==2) ? edCHINKL4 : 0);
14769
14770 if(tempguy.misc1==3 && !tempguy.weapon) tempguy.weapon = ewFlame;
14771
14772 tempguy.misc1--;
14773 }
14774 else if(tempguy.family == eeGLEEOK)
14775 {
14776 for(int32_t j=0; j<edefLAST; j++)
14777 tempguy.defense[j] = default_guys[eGLEEOK1].defense[j];
14778
14779 if(tempguy.misc3==1 && !tempguy.weapon) tempguy.weapon = ewFlame;
14780 }
14781 else if(tempguy.family == eeARMOS)
14782 {
14783 tempguy.family=eeWALK;
14784 tempguy.hrate = 0;
14785 tempguy.misc10 = tempguy.misc1;
14786 tempguy.misc1 = tempguy.misc2 = tempguy.misc3 = tempguy.misc4 = tempguy.misc5 = tempguy.misc6 = tempguy.misc7 = tempguy.misc8 = 0;
14787 tempguy.misc9 = e9tARMOS;
14788 }
14789 else if(tempguy.family == eeGHINI && !tempguy.misc1)
14790 {
14791 tempguy.family=eeWALK;
14792 tempguy.hrate = 0;
14793 tempguy.misc1 = tempguy.misc2 = tempguy.misc3 = tempguy.misc4 = tempguy.misc5 = tempguy.misc6 =
14794 tempguy.misc7 = tempguy.misc8 = tempguy.misc9 = tempguy.misc10 = 0;
14795 }
14796
14797 // Spawn animation flags
14798 if(tempguy.family == eeWALK && (tempguy.flags2&cmbflag_armos || tempguy.flags2&cmbflag_ghini))
14799 tempguy.flags |= guy_fadeflicker;
14800 else
14801 tempguy.flags &= 0x0F00000F; // Get rid of the unused flags!
14802 }
14803
14804
1/2
✓ Branch 0 taken 57344 times.
✗ Branch 1 not taken.
57344 if(guyversion < 20) // April 2010
14805 {
14806 if(tempguy.family == eeTRAP)
14807 {
14808 tempguy.misc2 = tempguy.misc10;
14809
14810 if(tempguy.misc10>=1)
14811 {
14812 tempguy.misc1++;
14813 }
14814
14815 tempguy.misc10 = 0;
14816 }
14817
14818 // Bomb Blast fix
14819 if(tempguy.weapon==ewBomb && tempguy.family!=eeROPE && (tempguy.family!=eeWALK || tempguy.misc2 != e2tBOMBCHU))
14820 tempguy.weapon = ewLitBomb;
14821 else if(tempguy.weapon==ewSBomb && tempguy.family!=eeROPE && (tempguy.family!=eeWALK || tempguy.misc2 != e2tBOMBCHU))
14822 tempguy.weapon = ewLitSBomb;
14823 }
14824
14825
1/2
✓ Branch 0 taken 57344 times.
✗ Branch 1 not taken.
57344 if(guyversion < 21) // September 2011
14826 {
14827 if(tempguy.family == eeKEESE || tempguy.family == eeKEESETRIB)
14828 {
14829 if(tempguy.family == eeKEESETRIB)
14830 {
14831 tempguy.family = eeKEESE;
14832 tempguy.misc2 = e2tKEESETRIB;
14833 tempguy.misc1 = 0;
14834 }
14835
14836 tempguy.rate = 2;
14837 tempguy.hrate = 8;
14838 tempguy.homing = 0;
14839 tempguy.step= (tempguy.family == eeKEESE && tempguy.misc1 ? 100:62);
14840 }
14841 else if(tempguy.family == eePEAHAT || tempguy.family==eePATRA)
14842 {
14843 if(tempguy.family == eePEAHAT)
14844 {
14845 tempguy.rate = 4;
14846 tempguy.step = 62;
14847 }
14848 else
14849 tempguy.step = 25;
14850
14851 tempguy.hrate = 8;
14852 tempguy.homing = 0;
14853 }
14854 else if(tempguy.family == eeDIG || tempguy.family == eeMANHAN)
14855 {
14856 if(tempguy.family == eeMANHAN)
14857 tempguy.step=50;
14858
14859 tempguy.hrate = 16;
14860 tempguy.homing = 0;
14861 }
14862 else if(tempguy.family == eeGLEEOK)
14863 {
14864 tempguy.rate = 2;
14865 tempguy.homing = 0;
14866 tempguy.hrate = 9;
14867 tempguy.step=89;
14868 }
14869 else if(tempguy.family == eeGHINI)
14870 {
14871 tempguy.rate = 4;
14872 tempguy.hrate = 12;
14873 tempguy.step=62;
14874 tempguy.homing = 0;
14875 }
14876
14877 // Bigdig random rate fix
14878 if(tempguy.family==eeDIG && tempguy.misc10==1)
14879 {
14880 tempguy.rate = 2;
14881 }
14882 }
14883
14884
1/2
✓ Branch 0 taken 57344 times.
✗ Branch 1 not taken.
57344 if(guyversion < 24) // November 2012
14885 {
14886 if(tempguy.family==eeLANM)
14887 tempguy.misc3 = 1;
14888 else if(tempguy.family==eeMOLD)
14889 tempguy.misc2 = 0;
14890 }
14891
14892
2/2
✓ Branch 0 taken 17920 times.
✓ Branch 1 taken 39424 times.
57344 if(guyversion < 33) //Whistle defence did not exist before this version of 2.54. -Z
14893 {
14894
2/2
✓ Branch 0 taken 660 times.
✓ Branch 1 taken 38764 times.
39424 if(tempguy.family!=eeDIG)
14895 {
14896 38764 tempguy.defense[edefWhistle] = edIGNORE; //Might need to be ignore, universally.
14897 38764 }
14898
14899 39424 }
14900 // does not seem to solve the issue!
14901
1/2
✓ Branch 0 taken 57344 times.
✗ Branch 1 not taken.
57344 if ( Header->zelda_version <= 0x210 )
14902 {
14903 al_trace("Detected version %d for dodongo patch.\n",Header->zelda_version);
14904 if ( tempguy.family == eeDONGO )
14905 {
14906 tempguy.deadsfx = 15; //In 2.10 and earlier, Dodongos used this as their death sound.
14907 }
14908 }
14909
14910
2/2
✓ Branch 0 taken 17920 times.
✓ Branch 1 taken 39424 times.
57344 if(guyversion >= 42)
14911 {
14912
2/2
✓ Branch 0 taken 16896 times.
✓ Branch 1 taken 1024 times.
17920 if(guyversion >= 47)
14913 {
14914
1/2
✓ Branch 0 taken 16896 times.
✗ Branch 1 not taken.
16896 if(!p_igetl(&(tempguy.moveflags),f))
14915 {
14916 return qe_invalid;
14917 }
14918 16896 }
14919 else
14920 {
14921 byte fl;
14922
1/2
✓ Branch 0 taken 1024 times.
✗ Branch 1 not taken.
1024 if(!p_getc(&fl,f))
14923 {
14924 return qe_invalid;
14925 }
14926 1024 tempguy.moveflags = fl;
14927 }
14928 17920 }
14929 else
14930 {
14931
7/8
✓ Branch 0 taken 446 times.
✓ Branch 1 taken 30899 times.
✓ Branch 2 taken 1202 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 518 times.
✓ Branch 5 taken 278 times.
✓ Branch 6 taken 241 times.
✓ Branch 7 taken 5840 times.
39424 switch(tempguy.family)
14932 {
14933 //No gravity; floats over pits
14934 case eeTEK: case eePEAHAT: case eeROCK: case eeTRAP:
14935 case eePROJECTILE: case eeSPINTILE: case eeKEESE: case eeFIRE:
14936 //Special (bosses, etc)
14937 case eeFAIRY: case eeGUY: case eeNONE: case eeZORA:
14938 case eeAQUA: case eeDIG: case eeGHOMA: case eeGANON:
14939 case eePATRA: case eeGLEEOK: case eeMOLD: case eeMANHAN:
14940 30899 tempguy.moveflags = FLAG_CAN_PITWALK;
14941 30899 break;
14942 //No gravity, but falls in pits
14943 case eeLEV:
14944 518 tempguy.moveflags = FLAG_CAN_PITFALL;
14945 518 break;
14946 //Bosses that respect pits
14947 case eeDONGO:
14948 278 tempguy.moveflags = FLAG_OBEYS_GRAV;
14949 278 break;
14950 case eeLANM:
14951 241 tempguy.moveflags = 0;
14952 241 break;
14953 //Gravity, floats over pits
14954 case eeWIZZ: case eeWALLM: case eeGHINI:
14955 1202 tempguy.moveflags = FLAG_OBEYS_GRAV | FLAG_CAN_PITWALK;
14956 1202 break;
14957 //Gravity and falls in pits
14958 case eeWALK:
14959
4/4
✓ Branch 0 taken 5519 times.
✓ Branch 1 taken 321 times.
✓ Branch 2 taken 280 times.
✓ Branch 3 taken 5239 times.
5840 if (tempguy.misc9==e9tPOLSVOICE||tempguy.misc9==e9tVIRE)
14960 601 break;
14961 [[fallthrough]];
14962 case eeOTHER:
14963 case eeSCRIPT01: case eeSCRIPT02: case eeSCRIPT03: case eeSCRIPT04: case eeSCRIPT05:
14964 case eeSCRIPT06: case eeSCRIPT07: case eeSCRIPT08: case eeSCRIPT09: case eeSCRIPT10:
14965 case eeSCRIPT11: case eeSCRIPT12: case eeSCRIPT13: case eeSCRIPT14: case eeSCRIPT15:
14966 case eeSCRIPT16: case eeSCRIPT17: case eeSCRIPT18: case eeSCRIPT19: case eeSCRIPT20:
14967 case eeFFRIENDLY01: case eeFFRIENDLY02: case eeFFRIENDLY03: case eeFFRIENDLY04: case eeFFRIENDLY05:
14968 case eeFFRIENDLY06: case eeFFRIENDLY07: case eeFFRIENDLY08: case eeFFRIENDLY09: case eeFFRIENDLY10:
14969 5685 tempguy.moveflags = FLAG_OBEYS_GRAV | FLAG_CAN_PITFALL;
14970 5685 }
14971 }
14972
2/2
✓ Branch 0 taken 17920 times.
✓ Branch 1 taken 39424 times.
57344 if(guyversion < 43)
14973 {
14974
2/2
✓ Branch 0 taken 32101 times.
✓ Branch 1 taken 7323 times.
39424 switch(tempguy.family)
14975 {
14976 //No gravity; floats over pits
14977 case eeTEK: case eePEAHAT: case eeROCK: case eeTRAP:
14978 case eePROJECTILE: case eeSPINTILE: case eeKEESE: case eeFIRE:
14979 //Special (bosses, etc)
14980 case eeFAIRY: case eeGUY: case eeNONE: case eeZORA:
14981 case eeAQUA: case eeDIG: case eeGHOMA: case eeGANON:
14982 case eePATRA: case eeGLEEOK: case eeMOLD: case eeMANHAN:
14983 case eeWIZZ: case eeWALLM: case eeGHINI:
14984 //Gravity, floats over pits
14985 32101 tempguy.moveflags |= FLAG_CAN_WATERWALK;
14986 32101 tempguy.moveflags |= FLAG_CAN_PITWALK;
14987 32101 break;
14988 }
14989 39424 }
14990
2/2
✓ Branch 0 taken 17920 times.
✓ Branch 1 taken 39424 times.
57344 if (guyversion < 44)
14991 {
14992
2/2
✓ Branch 0 taken 39054 times.
✓ Branch 1 taken 370 times.
39424 if ( tempguy.family == eeGHOMA )
14993 {
14994 370 tempguy.flags |= guy_fadeinstant;
14995 370 }
14996 39424 }
14997
2/2
✓ Branch 0 taken 17920 times.
✓ Branch 1 taken 39424 times.
57344 if (guyversion > 44)
14998 {
14999
1/2
✓ Branch 0 taken 17920 times.
✗ Branch 1 not taken.
17920 if(!p_getc(&(tempguy.spr_shadow),f))
15000 {
15001 return qe_invalid;
15002 }
15003
1/2
✓ Branch 0 taken 17920 times.
✗ Branch 1 not taken.
17920 if(!p_getc(&(tempguy.spr_death),f))
15004 {
15005 return qe_invalid;
15006 }
15007
1/2
✓ Branch 0 taken 17920 times.
✗ Branch 1 not taken.
17920 if(!p_getc(&(tempguy.spr_spawn),f))
15008 {
15009 return qe_invalid;
15010 }
15011 17920 }
15012 else
15013 {
15014
2/2
✓ Branch 0 taken 39271 times.
✓ Branch 1 taken 153 times.
39424 tempguy.spr_shadow = (tempguy.family==eeROCK && tempguy.misc10==1) ? iwLargeShadow : iwShadow;
15015 39424 tempguy.spr_death = iwDeath;
15016 39424 tempguy.spr_spawn = iwSpawn;
15017 }
15018
15019
2/2
✓ Branch 0 taken 17920 times.
✓ Branch 1 taken 39424 times.
57344 if(guyversion < 46)
15020 {
15021
4/4
✓ Branch 0 taken 5840 times.
✓ Branch 1 taken 33584 times.
✓ Branch 2 taken 5519 times.
✓ Branch 3 taken 321 times.
39424 if(tempguy.family == eeWALK && tempguy.misc9 == e9tPOLSVOICE)
15022 {
15023 321 tempguy.moveflags |= FLAG_CAN_WATERWALK;
15024 321 }
15025 39424 }
15026
15027
1/2
✓ Branch 0 taken 57344 times.
✗ Branch 1 not taken.
57344 if(loading_tileset_flags & TILESET_CLEARSCRIPTS)
15028 {
15029 tempguy.script = 0;
15030 for(int q = 0; q < 8; ++q)
15031 tempguy.initD[q] = 0;
15032 }
15033 57344 guysbuf[i] = tempguy;
15034 57344 }
15035 112 }
15036
15037 112 return 0;
15038 128 }
15039
15040 void update_guy_1(guydata *tempguy) // November 2009
15041 {
15042 bool doesntcount = false;
15043 tempguy->flags &= ~weak_arrow; // Formerly 'weak to arrow' which wasn't implemented
15044
15045 switch(tempguy->family)
15046 {
15047 case 1: //eeWALK
15048 switch(tempguy->misc10)
15049 {
15050 case 0: //Stalfos
15051 if(tempguy->misc1==1) // Fires four projectiles at once
15052 tempguy->misc1=4;
15053
15054 break;
15055
15056 case 1: //Darknut
15057 goto darknuts;
15058 break;
15059 }
15060
15061 tempguy->misc10 = 0;
15062 break;
15063
15064 case 2: //eeSHOOT
15065 tempguy->family = eeWALK;
15066
15067 switch(tempguy->misc10)
15068 {
15069 case 0: //Octorok
15070 if(tempguy->misc1==1||tempguy->misc1==2)
15071 {
15072 tempguy->misc1=e1tFIREOCTO;
15073 tempguy->misc2=e2tFIREOCTO;
15074 }
15075 else tempguy->misc1 = 0;
15076
15077 tempguy->misc6=tempguy->misc4;
15078 tempguy->misc4=tempguy->misc3;
15079 tempguy->misc3=0;
15080 break;
15081
15082 case 1: // Moblin
15083 tempguy->misc1 = 0;
15084 break;
15085
15086 case 2: //Lynel
15087 tempguy->misc6=tempguy->misc1+1;
15088 tempguy->misc1=0;
15089 break;
15090
15091 case 3: //Stalfos 2
15092 if(tempguy->misc1==1) // Fires four projectiles at once
15093 tempguy->misc1=e1t4SHOTS;
15094 else tempguy->misc1 = 0;
15095
15096 break;
15097
15098 case 4: //Darknut 5
15099 darknuts:
15100 tempguy->defense[edefFIRE] = edIGNORE;
15101 tempguy->defense[edefBRANG] = edSTUNORCHINK;
15102 tempguy->defense[edefHOOKSHOT] = 0;
15103 tempguy->defense[edefARROW] = tempguy->defense[edefBYRNA] = tempguy->defense[edefREFROCK] =
15104 tempguy->defense[edefMAGIC] = tempguy->defense[edefSTOMP] = edCHINK;
15105
15106 if(tempguy->misc1==1)
15107 tempguy->misc1=2;
15108 else if(tempguy->misc1==2)
15109 {
15110 tempguy->misc4=tempguy->misc3;
15111 tempguy->misc3=tempguy->misc2;
15112 tempguy->misc2=e2tSPLIT;
15113 tempguy->misc1 = 0;
15114 }
15115 else tempguy->misc1 = 0;
15116
15117 tempguy->flags |= inv_front;
15118
15119 if(get_bit(deprecated_rules,qr_BRKBLSHLDS_DEP))
15120 tempguy->flags |= guy_bkshield;
15121
15122 break;
15123 }
15124
15125 tempguy->misc10 = 0;
15126 break;
15127
15128 /*
15129 case 9: //eeARMOS
15130 tempguy->family = eeWALK;
15131 break;
15132 */
15133 case 11: //eeGEL
15134 case 33: //eeGELTRIB
15135 if(tempguy->family==33)
15136 {
15137 tempguy->misc4 = 1;
15138
15139 if(get_bit(deprecated_rules, qr_OLDTRIBBLES_DEP)) //Old Tribbles
15140 tempguy->misc3 = tempguy->misc2;
15141
15142 tempguy->misc2 = e2tTRIBBLE;
15143 }
15144 else
15145 {
15146 tempguy->misc4 = 0;
15147 tempguy->misc3 = 0;
15148 tempguy->misc2 = 0;
15149 }
15150
15151 tempguy->family = eeWALK;
15152
15153 if(tempguy->misc1)
15154 {
15155 tempguy->misc1=1;
15156 tempguy->weapon = ewFireTrail;
15157 }
15158
15159 break;
15160
15161 case 34: //eeZOLTRIB
15162 case 12: //eeZOL
15163 tempguy->misc4=tempguy->misc3;
15164 tempguy->misc3=tempguy->misc2;
15165 tempguy->family = eeWALK;
15166 tempguy->misc2=e2tSPLITHIT;
15167
15168 if(tempguy->misc1)
15169 {
15170 tempguy->misc1=1;
15171 tempguy->weapon = ewFireTrail;
15172 }
15173
15174 break;
15175
15176 case 13: //eeROPE
15177 tempguy->family = eeWALK;
15178 tempguy->misc9 = e9tROPE;
15179
15180 if(tempguy->misc1)
15181 {
15182 tempguy->misc4 = tempguy->misc3;
15183 tempguy->misc3 = tempguy->misc2;
15184 tempguy->misc2 = e2tBOMBCHU;
15185 }
15186
15187 tempguy->misc1 = 0;
15188 break;
15189
15190 case 14: //eeGORIYA
15191 tempguy->family = eeWALK;
15192
15193 if(tempguy->misc1!=2) tempguy->misc1 = 0;
15194
15195 break;
15196
15197 case 17: //eeBUBBLE
15198 tempguy->family = eeWALK;
15199 tempguy->misc8 = tempguy->misc2;
15200 tempguy->misc7 = tempguy->misc1 + 1;
15201 tempguy->misc1 = tempguy->misc2 = 0;
15202
15203 //fallthrogh
15204 case eeTRAP:
15205 case eeROCK:
15206 doesntcount = true;
15207 break;
15208
15209 case 35: //eeVIRETRIB
15210 case 18: //eeVIRE
15211 tempguy->family = eeWALK;
15212 tempguy->misc4=tempguy->misc3;
15213 tempguy->misc3=tempguy->misc2;
15214 tempguy->misc2=e2tSPLITHIT;
15215 tempguy->misc9=e9tVIRE;
15216 break;
15217
15218 case 19: //eeLIKE
15219 tempguy->family = eeWALK;
15220 tempguy->misc7 = e7tEATITEMS;
15221 tempguy->misc8=95;
15222 break;
15223
15224 case 20: //eePOLSV
15225 tempguy->defense[edefBRANG] = edSTUNORCHINK;
15226 tempguy->defense[edefBOMB] = tempguy->defense[edefSBOMB] = tempguy->defense[edefFIRE] = edIGNORE;
15227 tempguy->defense[edefMAGIC] = tempguy->defense[edefBYRNA] = edCHINK;
15228 tempguy->defense[edefARROW] = ed1HKO;
15229 tempguy->defense[edefHOOKSHOT] = edSTUNONLY;
15230 tempguy->family = eeWALK;
15231 tempguy->misc9 = e9tPOLSVOICE;
15232 tempguy->rate = 4;
15233 tempguy->homing = 32;
15234 tempguy->hrate = 10;
15235 tempguy->grumble = 0;
15236 break;
15237
15238 case eeWIZZ:
15239 if(tempguy->misc4)
15240 {
15241 for(int32_t i=0; i < edefLAST; i++)
15242 tempguy->defense[i] = (i != edefREFBEAM && i != edefREFMAGIC && i != edefQUAKE) ? edIGNORE : 0;
15243 }
15244 else
15245 {
15246 tempguy->defense[edefBRANG] = edSTUNORCHINK;
15247 tempguy->defense[edefMAGIC] = edCHINK;
15248 tempguy->defense[edefHOOKSHOT] = edSTUNONLY;
15249 tempguy->defense[edefARROW] = tempguy->defense[edefFIRE] =
15250 tempguy->defense[edefWAND] = tempguy->defense[edefBYRNA] = edIGNORE;
15251 }
15252
15253 break;
15254
15255 case eePEAHAT:
15256 tempguy->flags &= ~(guy_superman|guy_sbombonly);
15257
15258 if(!(tempguy->flags & guy_bhit))
15259 tempguy->defense[edefBRANG] = edSTUNONLY;
15260
15261 break;
15262
15263 case eeLEV:
15264 tempguy->defense[edefSTOMP] = edCHINK;
15265 break;
15266 }
15267
15268 // Old flags
15269 if(tempguy->flags & guy_superman)
15270 {
15271 for(int32_t i = 0; i < edefLAST; i++)
15272 if(!(i==edefSBOMB && (tempguy->flags & guy_sbombonly)))
15273 tempguy->defense[i] = (i==edefBRANG && tempguy->defense[i] != edIGNORE
15274 && tempguy->family != eeROCK && tempguy->family != eeTRAP
15275 && tempguy->family != eePROJECTILE) ? edSTUNORIGNORE : edIGNORE;
15276 }
15277
15278 tempguy->flags &= ~(guy_superman|guy_sbombonly);
15279
15280 if(doesntcount)
15281 tempguy->flags |= (guy_doesntcount);
15282 }
15283
15284
15285 247176 int32_t readmapscreen_old(PACKFILE *f, zquestheader *Header, mapscr *temp_mapscr, word version)
15286 {
15287 byte tempbyte, padding;
15288 int32_t extras, secretcombos;
15289 //al_trace("readmapscreen Header->zelda_version: %x\n",Header->zelda_version);
15290
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 247176 times.
247176 if(!p_getc(&(temp_mapscr->valid),f))
15291 {
15292 return qe_invalid;
15293 }
15294
15295
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 247176 times.
247176 if(!p_getc(&(temp_mapscr->guy),f))
15296 return qe_invalid;
15297 247176 temp_mapscr->guytile = -1; //signal to use default guy values
15298
2/2
✓ Branch 0 taken 246700 times.
✓ Branch 1 taken 476 times.
247176 SETFLAG(temp_mapscr->roomflags,RFL_ALWAYS_GUY,temp_mapscr->guy==gFAIRY);
15299
4/4
✓ Branch 0 taken 476 times.
✓ Branch 1 taken 246700 times.
✓ Branch 2 taken 23 times.
✓ Branch 3 taken 453 times.
247176 SETFLAG(temp_mapscr->roomflags,RFL_GUYFIRES,temp_mapscr->guy!=gFAIRY || !get_qr(qr_NOFAIRYGUYFIRES));
15300
15301
3/6
✓ Branch 0 taken 240312 times.
✓ Branch 1 taken 6864 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 240312 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
247176 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<146)))
15302 {
15303
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6864 times.
6864 if(!p_getc(&tempbyte,f))
15304 {
15305 return qe_invalid;
15306 }
15307
15308 6864 temp_mapscr->str=tempbyte;
15309 6864 }
15310 else
15311 {
15312
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 240312 times.
240312 if(!p_igetw(&(temp_mapscr->str),f))
15313 {
15314 return qe_invalid;
15315 }
15316 }
15317
15318
1/2
✓ Branch 0 taken 247176 times.
✗ Branch 1 not taken.
247176 if(!p_getc(&(temp_mapscr->room),f))
15319 {
15320 return qe_invalid;
15321 }
15322
15323
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 247176 times.
247176 if(!p_getc(&(temp_mapscr->item),f))
15324 {
15325 return qe_invalid;
15326 }
15327
15328
3/6
✓ Branch 0 taken 153408 times.
✓ Branch 1 taken 93768 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 153408 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
247176 if(Header->zelda_version < 0x211 || (Header->zelda_version == 0x211 && Header->build < 14))
15329 {
15330 93768 temp_mapscr->hasitem = (temp_mapscr->item != 0) ? 1 : 0;
15331 93768 }
15332 else
15333 {
15334
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 153408 times.
153408 if(!p_getc(&(temp_mapscr->hasitem),f))
15335 return qe_invalid;
15336 }
15337
15338
2/4
✓ Branch 0 taken 240312 times.
✓ Branch 1 taken 6864 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
247176 if((Header->zelda_version < 0x192)||
15339
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 240312 times.
240312 ((Header->zelda_version == 0x192)&&(Header->build<154)))
15340 {
15341
1/2
✓ Branch 0 taken 6864 times.
✗ Branch 1 not taken.
6864 if(!p_getc(&tempbyte,f))
15342 {
15343 return qe_invalid;
15344 }
15345 6864 }
15346
15347
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 247176 times.
247176 if(!p_getc(&(temp_mapscr->tilewarptype[0]),f))
15348 {
15349 return qe_invalid;
15350 }
15351
15352
2/2
✓ Branch 0 taken 240312 times.
✓ Branch 1 taken 6864 times.
247176 if(Header->zelda_version < 0x193)
15353 {
15354
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6864 times.
6864 if(!p_getc(&tempbyte,f))
15355 {
15356 return qe_invalid;
15357 }
15358 6864 }
15359
15360
3/6
✓ Branch 0 taken 93768 times.
✓ Branch 1 taken 153408 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 93768 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
247176 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
15361 {
15362
2/2
✓ Branch 0 taken 460224 times.
✓ Branch 1 taken 153408 times.
613632 for(int32_t i=1; i<4; i++)
15363 {
15364
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 460224 times.
460224 if(!p_getc(&(temp_mapscr->tilewarptype[i]),f))
15365 {
15366 return qe_invalid;
15367 }
15368 460224 }
15369 153408 }
15370 else
15371 {
15372 93768 temp_mapscr->tilewarptype[1]=0;
15373 93768 temp_mapscr->tilewarptype[2]=0;
15374 93768 temp_mapscr->tilewarptype[3]=0;
15375 }
15376
15377
3/6
✓ Branch 0 taken 6864 times.
✓ Branch 1 taken 240312 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6864 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
247176 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>153)))
15378 {
15379
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 240312 times.
240312 if(!p_igetw(&(temp_mapscr->door_combo_set),f))
15380 {
15381 return qe_invalid;
15382 }
15383 240312 }
15384
15385
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 247176 times.
247176 if(!p_getc(&(temp_mapscr->warpreturnx[0]),f))
15386 {
15387 return qe_invalid;
15388 }
15389
15390 247176 temp_mapscr->warpreturnx[1]=0;
15391 247176 temp_mapscr->warpreturnx[2]=0;
15392 247176 temp_mapscr->warpreturnx[3]=0;
15393
15394
3/6
✓ Branch 0 taken 93768 times.
✓ Branch 1 taken 153408 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 93768 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
247176 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
15395 {
15396
2/2
✓ Branch 0 taken 460224 times.
✓ Branch 1 taken 153408 times.
613632 for(int32_t i=1; i<4; i++)
15397 {
15398
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 460224 times.
460224 if(!p_getc(&(temp_mapscr->warpreturnx[i]),f))
15399 {
15400 return qe_invalid;
15401 }
15402 460224 }
15403 153408 }
15404
15405
1/2
✓ Branch 0 taken 247176 times.
✗ Branch 1 not taken.
247176 if(!p_getc(&(temp_mapscr->warpreturny[0]),f))
15406 {
15407 return qe_invalid;
15408 }
15409
15410 247176 temp_mapscr->warpreturny[1]=0;
15411 247176 temp_mapscr->warpreturny[2]=0;
15412 247176 temp_mapscr->warpreturny[3]=0;
15413
15414
3/6
✓ Branch 0 taken 93768 times.
✓ Branch 1 taken 153408 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 93768 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
247176 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
15415 {
15416
2/2
✓ Branch 0 taken 460224 times.
✓ Branch 1 taken 153408 times.
613632 for(int32_t i=1; i<4; i++)
15417 {
15418
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 460224 times.
460224 if(!p_getc(&(temp_mapscr->warpreturny[i]),f))
15419 {
15420 return qe_invalid;
15421 }
15422 460224 }
15423
15424
1/2
✓ Branch 0 taken 153408 times.
✗ Branch 1 not taken.
153408 if(version>=18)
15425 {
15426
1/2
✓ Branch 0 taken 153408 times.
✗ Branch 1 not taken.
153408 if(!p_igetw(&temp_mapscr->warpreturnc,f))
15427 {
15428 return qe_invalid;
15429 }
15430 153408 }
15431 else
15432 {
15433 byte temp;
15434
15435 if(!p_getc(&temp,f))
15436 {
15437 return qe_invalid;
15438 }
15439
15440 temp_mapscr->warpreturnc=temp<<8|temp;
15441 }
15442 153408 }
15443
15444
1/2
✓ Branch 0 taken 247176 times.
✗ Branch 1 not taken.
247176 if(!p_getc(&(temp_mapscr->stairx),f))
15445
15446 {
15447 return qe_invalid;
15448 }
15449
15450
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 247176 times.
247176 if(!p_getc(&(temp_mapscr->stairy),f))
15451 {
15452 return qe_invalid;
15453 }
15454
15455
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 247176 times.
247176 if(!p_getc(&(temp_mapscr->itemx),f))
15456 {
15457 return qe_invalid;
15458 }
15459
15460
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 247176 times.
247176 if(!p_getc(&(temp_mapscr->itemy),f))
15461 {
15462 return qe_invalid;
15463 }
15464
15465
2/2
✓ Branch 0 taken 153408 times.
✓ Branch 1 taken 93768 times.
247176 if(version > 15) // February 2009
15466 {
15467
1/2
✓ Branch 0 taken 153408 times.
✗ Branch 1 not taken.
153408 if(!p_igetw(&(temp_mapscr->color),f))
15468 {
15469 return qe_invalid;
15470 }
15471 153408 }
15472 else
15473 {
15474
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 93768 times.
93768 if(!p_getc(& tempbyte,f))
15475 {
15476 return qe_invalid;
15477 }
15478
15479 93768 temp_mapscr->color = (word) tempbyte;
15480 }
15481
15482
1/2
✓ Branch 0 taken 247176 times.
✗ Branch 1 not taken.
247176 if(!p_getc(&(temp_mapscr->enemyflags),f))
15483 {
15484 return qe_invalid;
15485 }
15486
15487
2/2
✓ Branch 0 taken 988704 times.
✓ Branch 1 taken 247176 times.
1235880 for(int32_t k=0; k<4; k++)
15488 {
15489
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 988704 times.
988704 if(!p_getc(&(temp_mapscr->door[k]),f))
15490 {
15491 return qe_invalid;
15492
15493 }
15494 988704 }
15495
15496
2/2
✓ Branch 0 taken 93768 times.
✓ Branch 1 taken 153408 times.
247176 if(version <= 11)
15497 {
15498
1/2
✓ Branch 0 taken 93768 times.
✗ Branch 1 not taken.
93768 if(!p_getc(&(tempbyte),f))
15499 {
15500 return qe_invalid;
15501 }
15502
15503 93768 temp_mapscr->tilewarpdmap[0]=(word)tempbyte;
15504
15505
2/6
✓ Branch 0 taken 93768 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 93768 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
93768 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
15506 {
15507 for(int32_t i=1; i<4; i++)
15508 {
15509 if(!p_getc(&(tempbyte),f))
15510 {
15511 return qe_invalid;
15512 }
15513
15514 temp_mapscr->tilewarpdmap[i]=(word)tempbyte;
15515 }
15516 }
15517 else
15518 {
15519 93768 temp_mapscr->tilewarpdmap[1]=0;
15520 93768 temp_mapscr->tilewarpdmap[2]=0;
15521 93768 temp_mapscr->tilewarpdmap[3]=0;
15522 }
15523 93768 }
15524 else
15525 {
15526
2/2
✓ Branch 0 taken 613632 times.
✓ Branch 1 taken 153408 times.
767040 for(int32_t i=0; i<4; i++)
15527 {
15528
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 613632 times.
613632 if(!p_igetw(&(temp_mapscr->tilewarpdmap[i]),f))
15529 {
15530 return qe_invalid;
15531 }
15532 613632 }
15533 }
15534
15535
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 247176 times.
247176 if(!p_getc(&(temp_mapscr->tilewarpscr[0]),f))
15536 {
15537 return qe_invalid;
15538 }
15539
15540
3/6
✓ Branch 0 taken 93768 times.
✓ Branch 1 taken 153408 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 93768 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
247176 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
15541 {
15542
2/2
✓ Branch 0 taken 460224 times.
✓ Branch 1 taken 153408 times.
613632 for(int32_t i=1; i<4; i++)
15543 {
15544
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 460224 times.
460224 if(!p_getc(&(temp_mapscr->tilewarpscr[i]),f))
15545 {
15546 return qe_invalid;
15547 }
15548 460224 }
15549 153408 }
15550 else
15551 {
15552 93768 temp_mapscr->tilewarpscr[1]=0;
15553 93768 temp_mapscr->tilewarpscr[2]=0;
15554 93768 temp_mapscr->tilewarpscr[3]=0;
15555 }
15556
15557
2/2
✓ Branch 0 taken 153408 times.
✓ Branch 1 taken 93768 times.
247176 if(version >= 15)
15558 {
15559
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 153408 times.
153408 if(!p_getc(&(temp_mapscr->tilewarpoverlayflags),f))
15560 {
15561 return qe_invalid;
15562 }
15563 153408 }
15564 else
15565 {
15566 93768 temp_mapscr->tilewarpoverlayflags=0;
15567 }
15568
15569
1/2
✓ Branch 0 taken 247176 times.
✗ Branch 1 not taken.
247176 if(!p_getc(&(temp_mapscr->exitdir),f))
15570 {
15571 return qe_invalid;
15572 }
15573
15574
2/2
✓ Branch 0 taken 240312 times.
✓ Branch 1 taken 6864 times.
247176 if(Header->zelda_version < 0x193)
15575 {
15576
1/2
✓ Branch 0 taken 6864 times.
✗ Branch 1 not taken.
6864 if(!p_getc(&tempbyte,f))
15577 {
15578 return qe_invalid;
15579 }
15580
15581 6864 }
15582
15583
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 247176 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
247176 if((Header->zelda_version == 0x192)&&(Header->build>145)&&(Header->build<154))
15584 {
15585 if(!p_getc(&padding,f))
15586 {
15587 return qe_invalid;
15588 }
15589 }
15590
15591
2/2
✓ Branch 0 taken 2471760 times.
✓ Branch 1 taken 247176 times.
2718936 for(int32_t k=0; k<10; k++)
15592 {
15593 /*
15594 if (!temp_mapscr->enemy[k])
15595 {
15596 continue;
15597 }
15598 */
15599
3/6
✓ Branch 0 taken 2403120 times.
✓ Branch 1 taken 68640 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2403120 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
2471760 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<10)))
15600 {
15601
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 68640 times.
68640 if(!p_getc(&tempbyte,f))
15602 {
15603 return qe_invalid;
15604 }
15605
15606 68640 temp_mapscr->enemy[k]=tempbyte;
15607 68640 }
15608 else
15609 {
15610
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2403120 times.
2403120 if(!p_igetw(&(temp_mapscr->enemy[k]),f))
15611 {
15612 return qe_invalid;
15613 }
15614 }
15615
15616
3/6
✓ Branch 0 taken 2403120 times.
✓ Branch 1 taken 68640 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2403120 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
2471760 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<108)))
15617 {
15618 //using enumerations here is dangerous
15619 //very easy to break old quests -DD
15620
2/2
✓ Branch 0 taken 788 times.
✓ Branch 1 taken 67852 times.
68640 if(temp_mapscr->enemy[k]>=57) //old eGOHMA1
15621 {
15622 788 temp_mapscr->enemy[k]+=5;
15623 788 }
15624
2/2
✓ Branch 0 taken 67812 times.
✓ Branch 1 taken 40 times.
67852 else if(temp_mapscr->enemy[k]>=52) //old eGLEEOK2
15625 {
15626 40 temp_mapscr->enemy[k]+=1;
15627 40 }
15628 68640 }
15629
15630
2/2
✓ Branch 0 taken 1534080 times.
✓ Branch 1 taken 937680 times.
2471760 if(version < 9)
15631 {
15632
2/2
✓ Branch 0 taken 856505 times.
✓ Branch 1 taken 81175 times.
937680 if(temp_mapscr->enemy[k]>0)
15633 {
15634 81175 temp_mapscr->enemy[k]+=10;
15635 81175 }
15636 937680 }
15637 //don't read in any invalid data
15638
2/2
✓ Branch 0 taken 2471670 times.
✓ Branch 1 taken 90 times.
2471760 if ( ((unsigned)temp_mapscr->enemy[k]) > MAXGUYS )
15639 {
15640 90 al_trace("Tried to read an invalid enemy ID (%d) for tmpscr->enemy[%d]. This has been cleared to 0.\n", temp_mapscr->enemy[k], k);
15641 90 temp_mapscr->enemy[k] = 0;
15642 90 }
15643 2471760 }
15644
15645
1/2
✓ Branch 0 taken 247176 times.
✗ Branch 1 not taken.
247176 if(!p_getc(&(temp_mapscr->pattern),f))
15646 {
15647 return qe_invalid;
15648 }
15649
15650
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 247176 times.
247176 if(!p_getc(&(temp_mapscr->sidewarptype[0]),f))
15651 {
15652 return qe_invalid;
15653 }
15654
15655
3/6
✓ Branch 0 taken 93768 times.
✓ Branch 1 taken 153408 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 93768 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
247176 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
15656 {
15657
2/2
✓ Branch 0 taken 460224 times.
✓ Branch 1 taken 153408 times.
613632 for(int32_t i=1; i<4; i++)
15658 {
15659
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 460224 times.
460224 if(!p_getc(&(temp_mapscr->sidewarptype[i]),f))
15660 {
15661 return qe_invalid;
15662 }
15663 460224 }
15664 153408 }
15665 else
15666 {
15667 93768 temp_mapscr->sidewarptype[1]=0;
15668 93768 temp_mapscr->sidewarptype[2]=0;
15669 93768 temp_mapscr->sidewarptype[3]=0;
15670 }
15671
15672
2/2
✓ Branch 0 taken 153408 times.
✓ Branch 1 taken 93768 times.
247176 if(version >= 15)
15673 {
15674
1/2
✓ Branch 0 taken 153408 times.
✗ Branch 1 not taken.
153408 if(!p_getc(&(temp_mapscr->sidewarpoverlayflags),f))
15675 {
15676 return qe_invalid;
15677 }
15678 153408 }
15679 else
15680 {
15681 93768 temp_mapscr->sidewarpoverlayflags=0;
15682 }
15683
15684
1/2
✓ Branch 0 taken 247176 times.
✗ Branch 1 not taken.
247176 if(!p_getc(&(temp_mapscr->warparrivalx),f))
15685 {
15686 return qe_invalid;
15687 }
15688
15689
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 247176 times.
247176 if(!p_getc(&(temp_mapscr->warparrivaly),f))
15690 {
15691 return qe_invalid;
15692 }
15693
15694
2/2
✓ Branch 0 taken 988704 times.
✓ Branch 1 taken 247176 times.
1235880 for(int32_t k=0; k<4; k++)
15695 {
15696
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 988704 times.
988704 if(!p_getc(&(temp_mapscr->path[k]),f))
15697 {
15698 return qe_invalid;
15699 }
15700 988704 }
15701
15702
1/2
✓ Branch 0 taken 247176 times.
✗ Branch 1 not taken.
247176 if(!p_getc(&(temp_mapscr->sidewarpscr[0]),f))
15703 {
15704 return qe_invalid;
15705 }
15706
15707
3/6
✓ Branch 0 taken 93768 times.
✓ Branch 1 taken 153408 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 93768 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
247176 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
15708 {
15709
2/2
✓ Branch 0 taken 153408 times.
✓ Branch 1 taken 460224 times.
613632 for(int32_t i=1; i<4; i++)
15710 {
15711
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 460224 times.
460224 if(!p_getc(&(temp_mapscr->sidewarpscr[i]),f))
15712 {
15713 return qe_invalid;
15714 }
15715 460224 }
15716 153408 }
15717 else
15718 {
15719 93768 temp_mapscr->sidewarpscr[1]=0;
15720 93768 temp_mapscr->sidewarpscr[2]=0;
15721 93768 temp_mapscr->sidewarpscr[3]=0;
15722 }
15723
15724
2/2
✓ Branch 0 taken 93768 times.
✓ Branch 1 taken 153408 times.
247176 if(version <= 11)
15725 {
15726
1/2
✓ Branch 0 taken 93768 times.
✗ Branch 1 not taken.
93768 if(!p_getc(&(tempbyte),f))
15727 {
15728 return qe_invalid;
15729 }
15730
15731 93768 temp_mapscr->sidewarpdmap[0]=(word)tempbyte;
15732
15733
2/6
✓ Branch 0 taken 93768 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 93768 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
93768 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
15734 {
15735 for(int32_t i=1; i<4; i++)
15736 {
15737 if(!p_getc(&(tempbyte),f))
15738 {
15739 return qe_invalid;
15740 }
15741
15742 temp_mapscr->sidewarpdmap[i]=(word)tempbyte;
15743 }
15744 }
15745 else
15746 {
15747 93768 temp_mapscr->sidewarpdmap[1]=0;
15748 93768 temp_mapscr->sidewarpdmap[2]=0;
15749 93768 temp_mapscr->sidewarpdmap[3]=0;
15750 }
15751 93768 }
15752 else
15753 {
15754
2/2
✓ Branch 0 taken 613632 times.
✓ Branch 1 taken 153408 times.
767040 for(int32_t i=0; i<4; i++)
15755 {
15756
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 613632 times.
613632 if(!p_igetw(&(temp_mapscr->sidewarpdmap[i]),f))
15757 {
15758 return qe_invalid;
15759 }
15760 613632 }
15761 }
15762
15763
3/6
✓ Branch 0 taken 93768 times.
✓ Branch 1 taken 153408 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 93768 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
247176 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
15764 {
15765
1/2
✓ Branch 0 taken 153408 times.
✗ Branch 1 not taken.
153408 if(!p_getc(&(temp_mapscr->sidewarpindex),f))
15766 {
15767 return qe_invalid;
15768 }
15769 153408 }
15770 93768 else temp_mapscr->sidewarpindex = 0;
15771
15772
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 247176 times.
247176 if(!p_igetw(&(temp_mapscr->undercombo),f))
15773 {
15774 return qe_invalid;
15775 }
15776
15777
2/2
✓ Branch 0 taken 240312 times.
✓ Branch 1 taken 6864 times.
247176 if(Header->zelda_version < 0x193)
15778 {
15779
1/2
✓ Branch 0 taken 6864 times.
✗ Branch 1 not taken.
6864 if(!p_getc(&(temp_mapscr->old_cpage),f))
15780 {
15781 return qe_invalid;
15782 }
15783 6864 }
15784
15785
1/2
✓ Branch 0 taken 247176 times.
✗ Branch 1 not taken.
247176 if(!p_getc(&(temp_mapscr->undercset),f)) //recalculated for older quests
15786 {
15787 return qe_invalid;
15788 }
15789
15790
1/2
✓ Branch 0 taken 247176 times.
✗ Branch 1 not taken.
247176 if(!p_igetw(&(temp_mapscr->catchall),f))
15791 {
15792 return qe_invalid;
15793 }
15794
15795
1/2
✓ Branch 0 taken 247176 times.
✗ Branch 1 not taken.
247176 if(!p_getc(&(temp_mapscr->flags),f))
15796 {
15797 return qe_invalid;
15798 }
15799
15800
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 247176 times.
247176 if(!p_getc(&(temp_mapscr->flags2),f))
15801 {
15802 return qe_invalid;
15803 }
15804
15805
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 247176 times.
247176 if(!p_getc(&(temp_mapscr->flags3),f))
15806 {
15807 return qe_invalid;
15808 }
15809
15810
3/6
✓ Branch 0 taken 93768 times.
✓ Branch 1 taken 153408 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 93768 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
247176 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>1)))
15811 //if (version>2)
15812 {
15813
1/2
✓ Branch 0 taken 153408 times.
✗ Branch 1 not taken.
153408 if(!p_getc(&(temp_mapscr->flags4),f))
15814 {
15815 return qe_invalid;
15816 }
15817 153408 }
15818
15819
3/6
✓ Branch 0 taken 93768 times.
✓ Branch 1 taken 153408 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 93768 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
247176 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
15820 {
15821
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 153408 times.
153408 if(!p_getc(&(temp_mapscr->flags5),f))
15822 {
15823 return qe_invalid;
15824 }
15825
15826
1/2
✓ Branch 0 taken 153408 times.
✗ Branch 1 not taken.
153408 if(!p_igetw(&(temp_mapscr->noreset),f))
15827 {
15828 return qe_invalid;
15829 }
15830
15831
1/2
✓ Branch 0 taken 153408 times.
✗ Branch 1 not taken.
153408 if(!p_igetw(&(temp_mapscr->nocarry),f))
15832 {
15833 return qe_invalid;
15834 }
15835
15836
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 153408 times.
153408 if(temp_mapscr->flags5&32)
15837 {
15838 temp_mapscr->flags5 &= ~32;
15839 temp_mapscr->noreset |= 48;
15840 }
15841
15842
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 153408 times.
153408 if(version<8)
15843 {
15844 if(temp_mapscr->noreset&1)
15845 {
15846 temp_mapscr->noreset|=8192;
15847 }
15848
15849 if(temp_mapscr->nocarry&1)
15850 {
15851 temp_mapscr->nocarry|=8192;
15852 temp_mapscr->nocarry&=~1;
15853 }
15854 }
15855 153408 }
15856 else
15857 {
15858 93768 temp_mapscr->flags5 = 0;
15859 93768 temp_mapscr->noreset = 0;
15860 93768 temp_mapscr->nocarry = 0;
15861 }
15862
15863
3/6
✓ Branch 0 taken 93768 times.
✓ Branch 1 taken 153408 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 93768 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
247176 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>9)))
15864 {
15865
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 153408 times.
153408 if(!p_getc(&(temp_mapscr->flags6),f))
15866 {
15867 return qe_invalid;
15868 }
15869 153408 }
15870
15871
2/2
✓ Branch 0 taken 153408 times.
✓ Branch 1 taken 93768 times.
247176 if(version>5)
15872 {
15873
1/2
✓ Branch 0 taken 153408 times.
✗ Branch 1 not taken.
153408 if(!p_getc(&(temp_mapscr->flags7),f))
15874 {
15875 return qe_invalid;
15876 }
15877
15878
1/2
✓ Branch 0 taken 153408 times.
✗ Branch 1 not taken.
153408 if(!p_getc(&(temp_mapscr->flags8),f))
15879 {
15880 return qe_invalid;
15881 }
15882
15883
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 153408 times.
153408 if(!p_getc(&(temp_mapscr->flags9),f))
15884 {
15885 return qe_invalid;
15886 }
15887
15888
1/2
✓ Branch 0 taken 153408 times.
✗ Branch 1 not taken.
153408 if(!p_getc(&(temp_mapscr->flags10),f))
15889 {
15890 return qe_invalid;
15891 }
15892
15893
1/2
✓ Branch 0 taken 153408 times.
✗ Branch 1 not taken.
153408 if(!p_getc(&(temp_mapscr->csensitive),f))
15894 {
15895 return qe_invalid;
15896 }
15897 153408 }
15898 else
15899 {
15900 93768 temp_mapscr->csensitive=1;
15901 }
15902
15903
2/2
✓ Branch 0 taken 93768 times.
✓ Branch 1 taken 153408 times.
247176 if(version<14) // August 2007: screen SFX added
15904 {
15905
2/2
✓ Branch 0 taken 93668 times.
✓ Branch 1 taken 100 times.
93768 if(temp_mapscr->flags&8) //fROAR
15906 {
15907 100 temp_mapscr->bosssfx=
15908
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 91 times.
100 (temp_mapscr->flags3&2) ? WAV_DODONGO : // fDODONGO
15909 91 (temp_mapscr->flags2&32) ? WAV_VADER : // fVADER
15910 WAV_ROAR;
15911 100 }
15912
15913
2/2
✓ Branch 0 taken 91 times.
✓ Branch 1 taken 93677 times.
93768 if(temp_mapscr->flags&128) //fSEA
15914 {
15915 91 temp_mapscr->oceansfx=WAV_SEA;
15916 91 }
15917
15918 93768 temp_mapscr->secretsfx = (temp_mapscr->flags3&64) //fNOSECRETSOUND
15919 ? 0 : WAV_SECRET;
15920
15921 93768 temp_mapscr->flags3 &= ~66; //64|2
15922 93768 temp_mapscr->flags2 &= ~32;
15923 93768 temp_mapscr->flags &= ~136; // 128|8
15924 93768 }
15925 else
15926 {
15927
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 153408 times.
153408 if(!p_getc(&(temp_mapscr->oceansfx),f))
15928 {
15929 return qe_invalid;
15930 }
15931
15932
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 153408 times.
153408 if(!p_getc(&(temp_mapscr->bosssfx),f))
15933 {
15934 return qe_invalid;
15935 }
15936
15937
1/2
✓ Branch 0 taken 153408 times.
✗ Branch 1 not taken.
153408 if(!p_getc(&(temp_mapscr->secretsfx),f))
15938 {
15939 return qe_invalid;
15940 }
15941 }
15942
15943
2/2
✓ Branch 0 taken 93768 times.
✓ Branch 1 taken 153408 times.
247176 if(version<15) // October 2007: another SFX
15944 {
15945 93768 temp_mapscr->holdupsfx=WAV_PICKUP;
15946 93768 }
15947 else
15948 {
15949
1/2
✓ Branch 0 taken 153408 times.
✗ Branch 1 not taken.
153408 if(!p_getc(&(temp_mapscr->holdupsfx),f))
15950 {
15951 return qe_invalid;
15952 }
15953 }
15954
15955
15956
3/6
✓ Branch 0 taken 6864 times.
✓ Branch 1 taken 240312 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6864 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
247176 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>97)))
15957 {
15958
2/2
✓ Branch 0 taken 1441872 times.
✓ Branch 1 taken 240312 times.
1682184 for(int32_t k=0; k<6; k++)
15959 {
15960
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1441872 times.
1441872 if(!p_getc(&(temp_mapscr->layermap[k]),f))
15961 {
15962 return qe_invalid;
15963 }
15964 1441872 }
15965
15966
2/2
✓ Branch 0 taken 240312 times.
✓ Branch 1 taken 1441872 times.
1682184 for(int32_t k=0; k<6; k++)
15967 {
15968
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1441872 times.
1441872 if(!p_getc(&(temp_mapscr->layerscreen[k]),f))
15969 {
15970 return qe_invalid;
15971 }
15972 1441872 }
15973 240312 }
15974
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 6864 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
6864 else if((Header->zelda_version == 0x192)&&(Header->build>23)&&(Header->build<98))
15975 {
15976 if(!p_getc(&(temp_mapscr->layermap[2]),f))
15977 {
15978 return qe_invalid;
15979 }
15980
15981 if(!p_getc(&(temp_mapscr->layerscreen[2]),f))
15982 {
15983 return qe_invalid;
15984 }
15985
15986 if(!p_getc(&(temp_mapscr->layermap[4]),f))
15987 {
15988 return qe_invalid;
15989 }
15990
15991 if(!p_getc(&(temp_mapscr->layerscreen[4]),f))
15992
15993 {
15994 return qe_invalid;
15995 }
15996 }
15997
15998
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 247176 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
247176 if((Header->zelda_version == 0x192)&&(Header->build>149))
15999 {
16000 for(int32_t k=0; k<6; k++)
16001 {
16002 if(!p_getc(&tempbyte,f)) //layerxsize
16003 {
16004 return qe_invalid;
16005 }
16006 }
16007
16008 for(int32_t k=0; k<6; k++)
16009 {
16010 if(!p_getc(&tempbyte,f)) //layerxspeed
16011 {
16012 return qe_invalid;
16013 }
16014 }
16015
16016 for(int32_t k=0; k<6; k++)
16017 {
16018 if(!p_getc(&tempbyte,f)) //layerxdelay
16019 {
16020 return qe_invalid;
16021 }
16022 }
16023
16024 for(int32_t k=0; k<6; k++)
16025 {
16026 if(!p_getc(&tempbyte,f)) //layerysize
16027 {
16028 return qe_invalid;
16029 }
16030 }
16031
16032 for(int32_t k=0; k<6; k++)
16033 {
16034 if(!p_getc(&tempbyte,f)) //layeryspeed
16035 {
16036 return qe_invalid;
16037 }
16038 }
16039
16040 for(int32_t k=0; k<6; k++)
16041 {
16042 if(!p_getc(&tempbyte,f)) //layerydelay
16043 {
16044 return qe_invalid;
16045 }
16046 }
16047 }
16048
16049
3/6
✓ Branch 0 taken 6864 times.
✓ Branch 1 taken 240312 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6864 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
247176 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>149)))
16050 {
16051
2/2
✓ Branch 0 taken 1441872 times.
✓ Branch 1 taken 240312 times.
1682184 for(int32_t k=0; k<6; k++)
16052 {
16053
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1441872 times.
1441872 if(!p_getc(&(temp_mapscr->layeropacity[k]),f))
16054 {
16055 return qe_invalid;
16056 }
16057 1441872 }
16058 240312 }
16059
16060
3/6
✓ Branch 0 taken 6864 times.
✓ Branch 1 taken 240312 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6864 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
247176 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>153)))
16061 {
16062
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 240312 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
240312 if((Header->zelda_version == 0x192)&&(Header->build>153))
16063 {
16064 if(!p_getc(&padding,f))
16065 {
16066 return qe_invalid;
16067 }
16068 }
16069
16070
1/2
✓ Branch 0 taken 240312 times.
✗ Branch 1 not taken.
240312 if(!p_igetw(&(temp_mapscr->timedwarptics),f))
16071 {
16072 return qe_invalid;
16073 }
16074 240312 }
16075
16076
3/6
✓ Branch 0 taken 240312 times.
✓ Branch 1 taken 6864 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 240312 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
247176 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<24)))
16077 {
16078 6864 extras=15;
16079 6864 }
16080
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 240312 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
240312 else if(((Header->zelda_version == 0x192)&&(Header->build<98)))
16081 {
16082 extras=11;
16083 }
16084
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 240312 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
240312 else if((Header->zelda_version == 0x192)&&(Header->build<150))
16085 {
16086 extras=32;
16087 }
16088
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 240312 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
240312 else if((Header->zelda_version == 0x192)&&(Header->build<154))
16089 {
16090 extras=64;
16091 }
16092
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 240312 times.
240312 else if(Header->zelda_version < 0x193)
16093 {
16094 extras=62;
16095 }
16096 else
16097
16098 {
16099 240312 extras=0;
16100 }
16101
16102
2/2
✓ Branch 0 taken 102960 times.
✓ Branch 1 taken 247176 times.
350136 for(int32_t k=0; k<extras; k++)
16103 {
16104
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 102960 times.
102960 if(!p_getc(&tempbyte,f)) //extra[k]
16105 {
16106 return qe_invalid;
16107 }
16108 102960 }
16109
16110
3/6
✓ Branch 0 taken 93768 times.
✓ Branch 1 taken 153408 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 93768 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
247176 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>2)))
16111 //if (version>3)
16112 {
16113
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 153408 times.
153408 if(!p_getc(&(temp_mapscr->nextmap),f))
16114 {
16115 return qe_invalid;
16116 }
16117
16118
1/2
✓ Branch 0 taken 153408 times.
✗ Branch 1 not taken.
153408 if(!p_getc(&(temp_mapscr->nextscr),f))
16119 {
16120 return qe_invalid;
16121 }
16122 153408 }
16123 else
16124 {
16125 93768 temp_mapscr->nextmap=0;
16126 93768 temp_mapscr->nextscr=0;
16127 }
16128
16129
3/6
✓ Branch 0 taken 240312 times.
✓ Branch 1 taken 6864 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 240312 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
247176 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<137)))
16130 {
16131 6864 secretcombos=20;
16132 6864 }
16133
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 240312 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
240312 else if((Header->zelda_version == 0x192)&&(Header->build<154))
16134 {
16135 secretcombos=256;
16136 }
16137 else
16138 {
16139 240312 secretcombos=128;
16140 }
16141
16142
3/6
✓ Branch 0 taken 240312 times.
✓ Branch 1 taken 6864 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 240312 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
247176 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<154)))
16143 {
16144
2/2
✓ Branch 0 taken 137280 times.
✓ Branch 1 taken 6864 times.
144144 for(int32_t k=0; k<secretcombos; k++)
16145 {
16146
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 137280 times.
137280 if(!p_getc(&tempbyte,f))
16147 {
16148 return qe_invalid;
16149 }
16150
16151
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 137280 times.
137280 if(k<128)
16152 {
16153 137280 temp_mapscr->secretcombo[k]=tempbyte;
16154 137280 }
16155 137280 }
16156 6864 }
16157 else
16158 {
16159
2/2
✓ Branch 0 taken 30759936 times.
✓ Branch 1 taken 240312 times.
31000248 for(int32_t k=0; k<128; k++)
16160 {
16161
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 30759936 times.
30759936 if(!p_igetw(&(temp_mapscr->secretcombo[k]),f))
16162 {
16163 return qe_invalid;
16164 }
16165
16166 30759936 }
16167 }
16168
16169
3/6
✓ Branch 0 taken 6864 times.
✓ Branch 1 taken 240312 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6864 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
247176 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>153)))
16170 {
16171
2/2
✓ Branch 0 taken 30759936 times.
✓ Branch 1 taken 240312 times.
31000248 for(int32_t k=0; k<128; k++)
16172 {
16173
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 30759936 times.
30759936 if(!p_getc(&(temp_mapscr->secretcset[k]),f))
16174 {
16175 return qe_invalid;
16176 }
16177 30759936 }
16178
16179
2/2
✓ Branch 0 taken 30759936 times.
✓ Branch 1 taken 240312 times.
31000248 for(int32_t k=0; k<128; k++)
16180 {
16181
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 30759936 times.
30759936 if(!p_getc(&(temp_mapscr->secretflag[k]),f))
16182 {
16183 return qe_invalid;
16184 }
16185 30759936 }
16186 240312 }
16187
16188
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 247176 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
247176 if((Header->zelda_version == 0x192)&&(Header->build>97)&&(Header->build<154))
16189 {
16190 if(!p_getc(&padding,f))
16191 {
16192 return qe_invalid;
16193 }
16194 }
16195
16196
2/2
✓ Branch 0 taken 43502976 times.
✓ Branch 1 taken 247176 times.
43750152 for(int32_t k=0; k<176; k++)
16197 {
16198
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 43502976 times.
43502976 if(!p_igetw(&(temp_mapscr->data[k]),f))
16199 {
16200 return qe_invalid;
16201 }
16202 43502976 }
16203
16204
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 247176 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
247176 if((Header->zelda_version == 0x192)&&(Header->build>20)&&(Header->build<24))
16205 {
16206 if(!p_getc(&padding,f))
16207 {
16208 return qe_invalid;
16209 }
16210
16211 if(!p_getc(&padding,f))
16212 {
16213 return qe_invalid;
16214 }
16215 }
16216
16217
3/6
✓ Branch 0 taken 6864 times.
✓ Branch 1 taken 240312 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6864 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
247176 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>20)))
16218 {
16219
2/2
✓ Branch 0 taken 42294912 times.
✓ Branch 1 taken 240312 times.
42535224 for(int32_t k=0; k<176; k++)
16220 {
16221
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 42294912 times.
42294912 if(!p_getc(&(temp_mapscr->sflag[k]),f))
16222 {
16223 return qe_invalid;
16224 }
16225
16226
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 42294912 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
42294912 if((Header->zelda_version == 0x192)&&(Header->build<24))
16227 {
16228 if(!p_getc(&tempbyte,f))
16229 {
16230 return qe_invalid;
16231 }
16232
16233 if(!p_getc(&tempbyte,f))
16234 {
16235 return qe_invalid;
16236 }
16237
16238 if(!p_getc(&tempbyte,f))
16239 {
16240 return qe_invalid;
16241 }
16242 }
16243 42294912 }
16244 240312 }
16245
16246
3/6
✓ Branch 0 taken 6864 times.
✓ Branch 1 taken 240312 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6864 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
247176 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>97)))
16247 {
16248
2/2
✓ Branch 0 taken 240312 times.
✓ Branch 1 taken 42294912 times.
42535224 for(int32_t k=0; k<176; k++)
16249 {
16250
16251
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 42294912 times.
42294912 if(!p_getc(&(temp_mapscr->cset[k]),f))
16252 {
16253 return qe_invalid;
16254 }
16255 42294912 }
16256 240312 }
16257
16258
3/6
✓ Branch 0 taken 240312 times.
✓ Branch 1 taken 6864 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 240312 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
247176 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<154)))
16259 {
16260 6864 temp_mapscr->undercset=(temp_mapscr->undercombo>>8)&7;
16261 6864 temp_mapscr->undercombo=(temp_mapscr->undercombo&0xFF)+(temp_mapscr->old_cpage<<8);
16262 6864 }
16263
16264
3/6
✓ Branch 0 taken 240312 times.
✓ Branch 1 taken 6864 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 240312 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
247176 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<137)))
16265 {
16266 6864 temp_mapscr->secretcombo[sSBOMB]=temp_mapscr->secretcombo[sBOMB];
16267 6864 temp_mapscr->secretcombo[sRCANDLE]=temp_mapscr->secretcombo[sBCANDLE];
16268 6864 temp_mapscr->secretcombo[sWANDFIRE]=temp_mapscr->secretcombo[sBCANDLE];
16269 6864 temp_mapscr->secretcombo[sDIVINEFIRE]=temp_mapscr->secretcombo[sBCANDLE];
16270 6864 temp_mapscr->secretcombo[sSARROW]=temp_mapscr->secretcombo[sARROW];
16271 6864 temp_mapscr->secretcombo[sGARROW]=temp_mapscr->secretcombo[sARROW];
16272 6864 }
16273
16274
3/6
✓ Branch 0 taken 240312 times.
✓ Branch 1 taken 6864 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 240312 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
247176 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<154)))
16275 {
16276
2/2
✓ Branch 0 taken 1208064 times.
✓ Branch 1 taken 6864 times.
1214928 for(int32_t k=0; k<176; k++)
16277 {
16278
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1208064 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1208064 if((Header->zelda_version == 0x192)&&(Header->build>149))
16279 {
16280 if((Header->zelda_version == 0x192)&&(Header->build!=153))
16281 {
16282 temp_mapscr->cset[k]=((temp_mapscr->data[k]>>8)&7);
16283 }
16284 }
16285 else
16286 {
16287
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1208064 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1208064 if((Header->zelda_version < 0x192)||
16288 ((Header->zelda_version == 0x192)&&(Header->build<21)))
16289 {
16290 1208064 temp_mapscr->sflag[k]=(temp_mapscr->data[k]>>11);
16291 1208064 }
16292
16293 1208064 temp_mapscr->cset[k]=((temp_mapscr->data[k]>>8)&7);
16294 }
16295
16296 1208064 temp_mapscr->data[k]=(temp_mapscr->data[k]&0xFF)+(temp_mapscr->old_cpage<<8);
16297 1208064 }
16298 6864 }
16299
16300 /*if(version>12)
16301 {
16302 if(!p_getc(&(temp_mapscr->scrWidth),f))
16303 {
16304 return qe_invalid;
16305 }
16306 if(!p_getc(&(temp_mapscr->scrHeight),f))
16307 {
16308 return qe_invalid;
16309 }
16310 }*/
16311
16312
2/2
✓ Branch 0 taken 153408 times.
✓ Branch 1 taken 93768 times.
247176 if(version>4)
16313 {
16314
1/2
✓ Branch 0 taken 153408 times.
✗ Branch 1 not taken.
153408 if(!p_igetw(&(temp_mapscr->screen_midi),f))
16315 {
16316 return qe_invalid;
16317 }
16318 153408 }
16319 else
16320 {
16321 93768 temp_mapscr->screen_midi = -1;
16322 }
16323
16324
2/2
✓ Branch 0 taken 153408 times.
✓ Branch 1 taken 93768 times.
247176 if(version>=17)
16325 {
16326
1/2
✓ Branch 0 taken 153408 times.
✗ Branch 1 not taken.
153408 if(!p_getc(&(temp_mapscr->lens_layer),f))
16327 {
16328 return qe_invalid;
16329 }
16330 153408 }
16331 else
16332 {
16333 93768 temp_mapscr->lens_layer = llNORMAL;
16334 }
16335
16336
2/2
✓ Branch 0 taken 93768 times.
✓ Branch 1 taken 153408 times.
247176 if(version>6)
16337 {
16338 dword bits;
16339
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 153408 times.
153408 if(!p_igetl(&bits,f))
16340 {
16341 return qe_invalid;
16342 }
16343
16344 int32_t m;
16345 float tempfloat;
16346 word tempw;
16347 153408 temp_mapscr->ffcCountMarkDirty();
16348
16349
2/2
✓ Branch 0 taken 153408 times.
✓ Branch 1 taken 4909056 times.
5062464 for(m=0; m<32; m++)
16350 {
16351 4909056 ffcdata& tempffc = temp_mapscr->ffcs[m];
16352 4909056 tempffc.clear();
16353
2/2
✓ Branch 0 taken 4886067 times.
✓ Branch 1 taken 22989 times.
4909056 if((bits>>m)&1)
16354 {
16355
1/2
✓ Branch 0 taken 22989 times.
✗ Branch 1 not taken.
22989 if(!p_igetw(&tempw,f))
16356 {
16357 return qe_invalid;
16358 }
16359 22989 tempffc.data = tempw;
16360
16361
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22989 times.
22989 if(!p_getc(&(tempffc.cset),f))
16362 {
16363 return qe_invalid;
16364 }
16365
16366
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22989 times.
22989 if(!p_igetw(&(tempffc.delay),f))
16367 {
16368 return qe_invalid;
16369 }
16370
16371
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22989 times.
22989 if(version < 9)
16372 {
16373 if(!p_igetf_DO_NOT_USE(&tempfloat,f))
16374 {
16375 return qe_invalid;
16376 }
16377
16378 tempffc.x=zslongToFix(int32_t(tempfloat*10000));
16379
16380 if(!p_igetf_DO_NOT_USE(&tempfloat,f))
16381 {
16382 return qe_invalid;
16383 }
16384
16385 tempffc.y=zslongToFix(int32_t(tempfloat*10000));
16386
16387 if(!p_igetf_DO_NOT_USE(&tempfloat,f))
16388 {
16389 return qe_invalid;
16390 }
16391
16392 tempffc.vx=zslongToFix(int32_t(tempfloat*10000));
16393
16394 if(!p_igetf_DO_NOT_USE(&tempfloat,f))
16395 {
16396 return qe_invalid;
16397 }
16398
16399 tempffc.vy=zslongToFix(int32_t(tempfloat*10000));
16400
16401 if(!p_igetf_DO_NOT_USE(&tempfloat,f))
16402 {
16403 return qe_invalid;
16404 }
16405
16406 tempffc.ax=zslongToFix(int32_t(tempfloat*10000));
16407
16408 if(!p_igetf_DO_NOT_USE(&tempfloat,f))
16409 {
16410 return qe_invalid;
16411 }
16412
16413 tempffc.ay=zslongToFix(int32_t(tempfloat*10000));
16414 }
16415 else
16416 {
16417
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22989 times.
22989 if(!p_igetzf(&(tempffc.x),f))
16418 {
16419 return qe_invalid;
16420 }
16421
16422
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22989 times.
22989 if(!p_igetzf(&(tempffc.y),f))
16423 {
16424 return qe_invalid;
16425 }
16426
16427
1/2
✓ Branch 0 taken 22989 times.
✗ Branch 1 not taken.
22989 if(!p_igetzf(&(tempffc.vx),f))
16428 {
16429 return qe_invalid;
16430 }
16431
16432
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22989 times.
22989 if(!p_igetzf(&(tempffc.vy),f))
16433 {
16434 return qe_invalid;
16435 }
16436
16437
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22989 times.
22989 if(!p_igetzf(&(tempffc.ax),f))
16438 {
16439 return qe_invalid;
16440 }
16441
16442
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22989 times.
22989 if(!p_igetzf(&(tempffc.ay),f))
16443 {
16444 return qe_invalid;
16445 }
16446 }
16447
16448
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22989 times.
22989 if(!p_getc(&(tempffc.link),f))
16449 {
16450 return qe_invalid;
16451 }
16452
16453
1/2
✓ Branch 0 taken 22989 times.
✗ Branch 1 not taken.
22989 if(version>7)
16454 {
16455
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22989 times.
22989 if(!p_getc(&tempbyte,f))
16456 {
16457 return qe_invalid;
16458 }
16459
16460 22989 tempffc.hit_width = (tempbyte&0x3F)+1;
16461 22989 tempffc.txsz = (tempbyte>>6)+1;
16462
16463
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22989 times.
22989 if(!p_getc(&tempbyte,f))
16464 {
16465 return qe_invalid;
16466 }
16467
16468 22989 tempffc.hit_height = (tempbyte&0x3F)+1;
16469 22989 tempffc.tysz = (tempbyte>>6)+1;
16470
16471
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22989 times.
22989 if(!p_igetl(&(tempffc.flags),f))
16472 {
16473 return qe_invalid;
16474 }
16475 22989 }
16476 else
16477 {
16478 tempffc.hit_width=16;
16479 tempffc.hit_height=16;
16480 tempffc.txsz=1;
16481 tempffc.tysz=1;
16482 tempffc.flags=0;
16483 }
16484
16485 22989 tempffc.updateSolid();
16486
16487
16488
4/6
✓ Branch 0 taken 22989 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 20969 times.
✓ Branch 3 taken 2020 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 20969 times.
22989 if(Header->zelda_version == 0x211 || (Header->zelda_version == 0x250 && Header->build<20))
16489 {
16490 tempffc.flags|=ffIGNOREHOLDUP;
16491 }
16492
16493
1/2
✓ Branch 0 taken 22989 times.
✗ Branch 1 not taken.
22989 if(version>9)
16494 {
16495
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22989 times.
22989 if(!p_igetw(&(tempffc.script),f))
16496 {
16497 return qe_invalid;
16498 }
16499 22989 }
16500 else
16501 {
16502 tempffc.script=0;
16503 }
16504
16505
1/2
✓ Branch 0 taken 22989 times.
✗ Branch 1 not taken.
22989 if(version>10)
16506 {
16507
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22989 times.
22989 if(!p_igetl(&(tempffc.initd[0]),f))
16508 {
16509 return qe_invalid;
16510 }
16511
16512
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22989 times.
22989 if(!p_igetl(&(tempffc.initd[1]),f))
16513 {
16514 return qe_invalid;
16515 }
16516
16517
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22989 times.
22989 if(!p_igetl(&(tempffc.initd[2]),f))
16518 {
16519 return qe_invalid;
16520 }
16521
16522
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22989 times.
22989 if(!p_igetl(&(tempffc.initd[3]),f))
16523 {
16524 return qe_invalid;
16525 }
16526
16527
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22989 times.
22989 if(!p_igetl(&(tempffc.initd[4]),f))
16528 {
16529 return qe_invalid;
16530 }
16531
16532
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22989 times.
22989 if(!p_igetl(&(tempffc.initd[5]),f))
16533 {
16534 return qe_invalid;
16535 }
16536
16537
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22989 times.
22989 if(!p_igetl(&(tempffc.initd[6]),f))
16538 {
16539 return qe_invalid;
16540 }
16541
16542
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22989 times.
22989 if(!p_igetl(&(tempffc.initd[7]),f))
16543 {
16544 return qe_invalid;
16545 }
16546
16547
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22989 times.
22989 if(!p_getc(&(tempbyte),f))
16548 {
16549 return qe_invalid;
16550 }
16551
16552 22989 tempffc.inita[0]=tempbyte*10000;
16553
16554
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22989 times.
22989 if(!p_getc(&(tempbyte),f))
16555 {
16556 return qe_invalid;
16557 }
16558
16559 22989 tempffc.inita[1]=tempbyte*10000;
16560 22989 }
16561 else
16562 {
16563 tempffc.inita[0] = 10000;
16564 tempffc.inita[1] = 10000;
16565 }
16566
16567
1/2
✓ Branch 0 taken 22989 times.
✗ Branch 1 not taken.
22989 if(loading_tileset_flags & TILESET_CLEARSCRIPTS)
16568 {
16569 tempffc.script = 0;
16570 for(int q = 0; q < 8; ++q)
16571 tempffc.initd[q] = 0;
16572 }
16573
1/2
✓ Branch 0 taken 22989 times.
✗ Branch 1 not taken.
22989 if(version <= 11)
16574 {
16575 fixffcs=true;
16576 }
16577 22989 }
16578 4909056 }
16579
2/2
✓ Branch 0 taken 14727168 times.
✓ Branch 1 taken 153408 times.
14880576 for(m = 32; m < MAXFFCS; ++m)
16580 {
16581 14727168 temp_mapscr->ffcs[m].clear();
16582 14727168 }
16583 153408 }
16584
16585 //add in the new whistle flags
16586
2/2
✓ Branch 0 taken 153408 times.
✓ Branch 1 taken 93768 times.
247176 if(version<13)
16587 {
16588
2/2
✓ Branch 0 taken 19 times.
✓ Branch 1 taken 93749 times.
93768 if(temp_mapscr->flags & fWHISTLE)
16589 {
16590 19 temp_mapscr->flags7 |= (fWHISTLEPAL | fWHISTLEWATER);
16591 19 }
16592 93768 }
16593
16594 //2.55 starts here
16595
3/4
✓ Branch 0 taken 13736 times.
✓ Branch 1 taken 233440 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 13736 times.
247176 if ( version >= 19 && Header->zelda_version > 0x253 )
16596 {
16597
2/2
✓ Branch 0 taken 137360 times.
✓ Branch 1 taken 13736 times.
151096 for ( int32_t q = 0; q < 10; q++ )
16598 {
16599
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 137360 times.
137360 if(!p_igetl(&(temp_mapscr->npcstrings[q]),f))
16600 {
16601 return qe_invalid;
16602 }
16603 137360 }
16604
2/2
✓ Branch 0 taken 137360 times.
✓ Branch 1 taken 13736 times.
151096 for ( int32_t q = 0; q < 10; q++ )
16605 {
16606
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 137360 times.
137360 if(!p_igetw(&(temp_mapscr->new_items[q]),f))
16607 {
16608 return qe_invalid;
16609 }
16610 137360 }
16611
2/2
✓ Branch 0 taken 137360 times.
✓ Branch 1 taken 13736 times.
151096 for ( int32_t q = 0; q < 10; q++ )
16612 {
16613
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 137360 times.
137360 if(!p_igetw(&(temp_mapscr->new_item_x[q]),f))
16614 {
16615 return qe_invalid;
16616 }
16617 137360 }
16618
2/2
✓ Branch 0 taken 13736 times.
✓ Branch 1 taken 137360 times.
151096 for ( int32_t q = 0; q < 10; q++ )
16619 {
16620
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 137360 times.
137360 if(!p_igetw(&(temp_mapscr->new_item_y[q]),f))
16621 {
16622 return qe_invalid;
16623 }
16624 137360 }
16625 13736 }
16626
3/4
✓ Branch 0 taken 233440 times.
✓ Branch 1 taken 13736 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 233440 times.
247176 if ( version < 19 && Header->zelda_version > 0x253 )
16627 {
16628 for ( int32_t q = 0; q < 10; q++ )
16629 {
16630 temp_mapscr->npcstrings[q] = 0;
16631 temp_mapscr->new_items[q] = 0;
16632 temp_mapscr->new_item_x[q] = 0;
16633 temp_mapscr->new_item_y[q] = 0;
16634 }
16635 }
16636
3/4
✓ Branch 0 taken 13736 times.
✓ Branch 1 taken 233440 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 13736 times.
247176 if ( version >= 20 && Header->zelda_version > 0x253 )
16637 {
16638
1/2
✓ Branch 0 taken 13736 times.
✗ Branch 1 not taken.
13736 if(!p_igetw(&(temp_mapscr->script),f))
16639 {
16640 return qe_invalid;
16641 }
16642
2/2
✓ Branch 0 taken 109888 times.
✓ Branch 1 taken 13736 times.
123624 for ( int32_t q = 0; q < 8; q++)
16643 {
16644
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 109888 times.
109888 if(!p_igetl(&(temp_mapscr->screeninitd[q]),f))
16645 {
16646 return qe_invalid;
16647 }
16648 109888 }
16649 13736 }
16650
2/2
✓ Branch 0 taken 13736 times.
✓ Branch 1 taken 233440 times.
247176 if ( version < 20 )
16651 {
16652 233440 temp_mapscr->script = 0;
16653
2/2
✓ Branch 0 taken 1867520 times.
✓ Branch 1 taken 233440 times.
2100960 for ( int32_t q = 0; q < 8; q++) temp_mapscr->screeninitd[q] = 0;
16654 233440 }
16655
3/4
✓ Branch 0 taken 13736 times.
✓ Branch 1 taken 233440 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 13736 times.
247176 if ( version >= 21 && Header->zelda_version > 0x253 )
16656 {
16657
1/2
✓ Branch 0 taken 13736 times.
✗ Branch 1 not taken.
13736 if(!p_getc(&(temp_mapscr->preloadscript),f))
16658 {
16659 return qe_invalid;
16660 }
16661 13736 }
16662
2/2
✓ Branch 0 taken 233440 times.
✓ Branch 1 taken 13736 times.
247176 if ( version < 21 )
16663 {
16664 233440 temp_mapscr->preloadscript = 0;
16665 233440 }
16666 //all builds with version > 20 need this. -Z
16667
16668
3/4
✓ Branch 0 taken 13736 times.
✓ Branch 1 taken 233440 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 13736 times.
247176 if ( version >= 22 && Header->zelda_version > 0x253 ) //26th June, 2019; Layer Visibility
16669 {
16670
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13736 times.
13736 if(!p_getc(&(temp_mapscr->hidelayers ),f))
16671 {
16672 return qe_invalid;
16673 }
16674
1/2
✓ Branch 0 taken 13736 times.
✗ Branch 1 not taken.
13736 if(!p_getc(&(temp_mapscr->hidescriptlayers ),f))
16675 {
16676 return qe_invalid;
16677 }
16678 13736 }
16679
2/2
✓ Branch 0 taken 233440 times.
✓ Branch 1 taken 13736 times.
247176 if ( version < 22 )
16680 {
16681 233440 temp_mapscr->hidelayers = 0;
16682 233440 temp_mapscr->hidescriptlayers = 0;
16683 233440 }
16684
16685 //Dodongos in 2.10 used the boss roar, not the dodongo sound. -Z
16686 //May be any version before 2.11. -Z
16687 /* --not the roar, the HIT SFX
16688 if ( Header->zelda_version <= 0x210 )
16689 {
16690 if ( temp_mapscr->bosssfx == WAV_DODONGO )
16691 {
16692 temp_mapscr->bosssfx = WAV_ROAR;
16693 }
16694 }
16695 */
16696
16697 247176 return 0;
16698 247176 }
16699 263360 int32_t readmapscreen(PACKFILE *f, zquestheader *Header, mapscr *temp_mapscr, word version, int scrind)
16700 {
16701
2/2
✓ Branch 0 taken 247176 times.
✓ Branch 1 taken 16184 times.
263360 if(version < 23)
16702 {
16703 247176 auto ret = readmapscreen_old(f,Header,temp_mapscr,version);
16704
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 247176 times.
247176 if(ret) return ret;
16705 247176 }
16706 else
16707 {
16708
1/2
✓ Branch 0 taken 16184 times.
✗ Branch 1 not taken.
16184 if(!p_getc(&(temp_mapscr->valid),f))
16709 return qe_invalid;
16710
2/2
✓ Branch 0 taken 10147 times.
✓ Branch 1 taken 6037 times.
16184 if(!(temp_mapscr->valid & mVALID))
16711 {
16712 10147 int map = scrind/MAPSCRS;
16713 10147 int scr = scrind%MAPSCRS;
16714
4/6
✓ Branch 0 taken 6336 times.
✓ Branch 1 taken 3811 times.
✓ Branch 2 taken 6336 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 6336 times.
✗ Branch 5 not taken.
10147 if(version > 25 && scrind > -1 && (map*6+5) < map_autolayers.size())
16715 {
16716 //Empty screen, apply autolayers
16717
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6336 times.
6336 for(int q = 0; q < 6; ++q)
16718 {
16719 auto layermap = map_autolayers[map*6+q];
16720 temp_mapscr->layermap[q] = layermap;
16721 if(layermap)
16722 temp_mapscr->layerscreen[q] = scr;
16723 }
16724 6336 }
16725 10147 return 0;
16726 }
16727 uint32_t scr_has_flags;
16728
1/2
✓ Branch 0 taken 6037 times.
✗ Branch 1 not taken.
6037 if(!p_igetl(&scr_has_flags,f))
16729 return qe_invalid;
16730
16731
2/2
✓ Branch 0 taken 5241 times.
✓ Branch 1 taken 796 times.
6037 if(scr_has_flags & SCRHAS_ROOMDATA)
16732 {
16733
1/2
✓ Branch 0 taken 796 times.
✗ Branch 1 not taken.
796 if(!p_getc(&(temp_mapscr->guy),f))
16734 return qe_invalid;
16735
2/2
✓ Branch 0 taken 736 times.
✓ Branch 1 taken 60 times.
796 if(version > 26)
16736 {
16737
1/2
✓ Branch 0 taken 736 times.
✗ Branch 1 not taken.
736 if(!p_igetl(&(temp_mapscr->guytile),f))
16738 return qe_invalid;
16739
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 736 times.
736 if(!p_getc(&(temp_mapscr->guycs),f))
16740 return qe_invalid;
16741
1/2
✓ Branch 0 taken 736 times.
✗ Branch 1 not taken.
736 if(!p_igetw(&(temp_mapscr->roomflags),f))
16742 return qe_invalid;
16743 736 }
16744 else
16745 {
16746 60 temp_mapscr->guytile = -1; //signal to use default guy values
16747
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 60 times.
60 SETFLAG(temp_mapscr->roomflags,RFL_ALWAYS_GUY,temp_mapscr->guy==gFAIRY);
16748
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 60 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
60 SETFLAG(temp_mapscr->roomflags,RFL_GUYFIRES,temp_mapscr->guy!=gFAIRY || !get_qr(qr_NOFAIRYGUYFIRES));
16749 }
16750
1/2
✓ Branch 0 taken 796 times.
✗ Branch 1 not taken.
796 if(!p_igetw(&(temp_mapscr->str),f))
16751 return qe_invalid;
16752
1/2
✓ Branch 0 taken 796 times.
✗ Branch 1 not taken.
796 if(!p_getc(&(temp_mapscr->room),f))
16753 return qe_invalid;
16754
1/2
✓ Branch 0 taken 796 times.
✗ Branch 1 not taken.
796 if(!p_igetw(&(temp_mapscr->catchall),f))
16755 return qe_invalid;
16756 796 }
16757
2/2
✓ Branch 0 taken 5916 times.
✓ Branch 1 taken 121 times.
6037 if(scr_has_flags & SCRHAS_ITEM)
16758 {
16759
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 121 times.
121 if(!p_getc(&(temp_mapscr->item),f))
16760 return qe_invalid;
16761
1/2
✓ Branch 0 taken 121 times.
✗ Branch 1 not taken.
121 if(!p_getc(&(temp_mapscr->hasitem),f))
16762 return qe_invalid;
16763
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 121 times.
121 if(!p_getc(&(temp_mapscr->itemx),f))
16764 return qe_invalid;
16765
1/2
✓ Branch 0 taken 121 times.
✗ Branch 1 not taken.
121 if(!p_getc(&(temp_mapscr->itemy),f))
16766 return qe_invalid;
16767 121 }
16768
2/2
✓ Branch 0 taken 5681 times.
✓ Branch 1 taken 356 times.
6037 if(scr_has_flags & (SCRHAS_SWARP|SCRHAS_TWARP))
16769 {
16770
1/2
✓ Branch 0 taken 356 times.
✗ Branch 1 not taken.
356 if(!p_igetw(&temp_mapscr->warpreturnc,f))
16771 return qe_invalid;
16772 356 }
16773
2/2
✓ Branch 0 taken 5794 times.
✓ Branch 1 taken 243 times.
6037 if(scr_has_flags & SCRHAS_TWARP)
16774 {
16775
2/2
✓ Branch 0 taken 972 times.
✓ Branch 1 taken 243 times.
1215 for(int32_t i=0; i<4; i++)
16776 {
16777
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 972 times.
972 if(!p_getc(&(temp_mapscr->tilewarptype[i]),f))
16778 return qe_invalid;
16779 972 }
16780
2/2
✓ Branch 0 taken 972 times.
✓ Branch 1 taken 243 times.
1215 for(int32_t i=0; i<4; i++)
16781 {
16782
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 972 times.
972 if(!p_igetw(&(temp_mapscr->tilewarpdmap[i]),f))
16783 return qe_invalid;
16784 972 }
16785
2/2
✓ Branch 0 taken 972 times.
✓ Branch 1 taken 243 times.
1215 for(int32_t i=0; i<4; i++)
16786 {
16787
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 972 times.
972 if(!p_getc(&(temp_mapscr->tilewarpscr[i]),f))
16788 return qe_invalid;
16789 972 }
16790
1/2
✓ Branch 0 taken 243 times.
✗ Branch 1 not taken.
243 if(!p_getc(&(temp_mapscr->tilewarpoverlayflags),f))
16791 return qe_invalid;
16792 243 }
16793
2/2
✓ Branch 0 taken 5898 times.
✓ Branch 1 taken 139 times.
6037 if(scr_has_flags & SCRHAS_SWARP)
16794 {
16795
2/2
✓ Branch 0 taken 556 times.
✓ Branch 1 taken 139 times.
695 for(int32_t i=0; i<4; i++)
16796 {
16797
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 556 times.
556 if(!p_getc(&(temp_mapscr->sidewarptype[i]),f))
16798 return qe_invalid;
16799 556 }
16800
2/2
✓ Branch 0 taken 556 times.
✓ Branch 1 taken 139 times.
695 for(int32_t i=0; i<4; i++)
16801 {
16802
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 556 times.
556 if(!p_igetw(&(temp_mapscr->sidewarpdmap[i]),f))
16803 return qe_invalid;
16804 556 }
16805
2/2
✓ Branch 0 taken 556 times.
✓ Branch 1 taken 139 times.
695 for(int32_t i=0; i<4; i++)
16806 {
16807
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 556 times.
556 if(!p_getc(&(temp_mapscr->sidewarpscr[i]),f))
16808 return qe_invalid;
16809 556 }
16810
1/2
✓ Branch 0 taken 139 times.
✗ Branch 1 not taken.
139 if(!p_getc(&(temp_mapscr->sidewarpoverlayflags),f))
16811 return qe_invalid;
16812
1/2
✓ Branch 0 taken 139 times.
✗ Branch 1 not taken.
139 if(!p_getc(&(temp_mapscr->sidewarpindex),f))
16813 return qe_invalid;
16814 139 }
16815
2/2
✓ Branch 0 taken 5605 times.
✓ Branch 1 taken 432 times.
6037 if(scr_has_flags & SCRHAS_WARPRET)
16816 {
16817
2/2
✓ Branch 0 taken 1728 times.
✓ Branch 1 taken 432 times.
2160 for(int32_t i=0; i<4; i++)
16818 {
16819
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1728 times.
1728 if(!p_getc(&(temp_mapscr->warpreturnx[i]),f))
16820 return qe_invalid;
16821 1728 }
16822
2/2
✓ Branch 0 taken 1728 times.
✓ Branch 1 taken 432 times.
2160 for(int32_t i=0; i<4; i++)
16823 {
16824
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1728 times.
1728 if(!p_getc(&(temp_mapscr->warpreturny[i]),f))
16825 return qe_invalid;
16826 1728 }
16827
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 432 times.
432 if(!p_getc(&(temp_mapscr->warparrivalx),f))
16828 return qe_invalid;
16829
1/2
✓ Branch 0 taken 432 times.
✗ Branch 1 not taken.
432 if(!p_getc(&(temp_mapscr->warparrivaly),f))
16830 return qe_invalid;
16831 432 }
16832
2/2
✓ Branch 0 taken 4911 times.
✓ Branch 1 taken 1126 times.
6037 if(scr_has_flags & SCRHAS_LAYERS)
16833 {
16834
2/2
✓ Branch 0 taken 6756 times.
✓ Branch 1 taken 1126 times.
7882 for(int32_t k=0; k<6; k++)
16835 {
16836
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6756 times.
6756 if(!p_getc(&(temp_mapscr->layermap[k]),f))
16837 return qe_invalid;
16838 6756 }
16839
2/2
✓ Branch 0 taken 6756 times.
✓ Branch 1 taken 1126 times.
7882 for(int32_t k=0; k<6; k++)
16840 {
16841
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6756 times.
6756 if(!p_getc(&(temp_mapscr->layerscreen[k]),f))
16842 return qe_invalid;
16843 6756 }
16844
2/2
✓ Branch 0 taken 6756 times.
✓ Branch 1 taken 1126 times.
7882 for(int32_t k=0; k<6; k++)
16845 {
16846
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6756 times.
6756 if(!p_getc(&(temp_mapscr->layeropacity[k]),f))
16847 return qe_invalid;
16848 6756 }
16849
1/2
✓ Branch 0 taken 1126 times.
✗ Branch 1 not taken.
1126 if(!p_getc(&(temp_mapscr->hidelayers),f))
16850 return qe_invalid;
16851
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1126 times.
1126 if(!p_getc(&(temp_mapscr->hidescriptlayers),f))
16852 return qe_invalid;
16853 1126 }
16854
1/2
✓ Branch 0 taken 6037 times.
✗ Branch 1 not taken.
6037 if(scr_has_flags & SCRHAS_MAZE)
16855 {
16856 for(int32_t k=0; k<4; k++)
16857 {
16858 if(!p_getc(&(temp_mapscr->path[k]),f))
16859 return qe_invalid;
16860 }
16861 if(!p_getc(&(temp_mapscr->exitdir),f))
16862 return qe_invalid;
16863 }
16864
2/2
✓ Branch 0 taken 5884 times.
✓ Branch 1 taken 153 times.
6037 if(scr_has_flags & SCRHAS_D_S_U)
16865 {
16866
1/2
✓ Branch 0 taken 153 times.
✗ Branch 1 not taken.
153 if(!p_igetw(&(temp_mapscr->door_combo_set),f))
16867 return qe_invalid;
16868
2/2
✓ Branch 0 taken 612 times.
✓ Branch 1 taken 153 times.
765 for(int32_t k=0; k<4; k++)
16869 {
16870
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 612 times.
612 if(!p_getc(&(temp_mapscr->door[k]),f))
16871 return qe_invalid;
16872 612 }
16873
16874
1/2
✓ Branch 0 taken 153 times.
✗ Branch 1 not taken.
153 if(!p_getc(&(temp_mapscr->stairx),f))
16875 return qe_invalid;
16876
16877
1/2
✓ Branch 0 taken 153 times.
✗ Branch 1 not taken.
153 if(!p_getc(&(temp_mapscr->stairy),f))
16878 return qe_invalid;
16879
1/2
✓ Branch 0 taken 153 times.
✗ Branch 1 not taken.
153 if(!p_igetw(&(temp_mapscr->undercombo),f))
16880 return qe_invalid;
16881
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 153 times.
153 if(!p_getc(&(temp_mapscr->undercset),f))
16882 return qe_invalid;
16883 153 }
16884
2/2
✓ Branch 0 taken 5604 times.
✓ Branch 1 taken 433 times.
6037 if(scr_has_flags & SCRHAS_FLAGS)
16885 {
16886
1/2
✓ Branch 0 taken 433 times.
✗ Branch 1 not taken.
433 if(!p_getc(&(temp_mapscr->flags),f))
16887 return qe_invalid;
16888
1/2
✓ Branch 0 taken 433 times.
✗ Branch 1 not taken.
433 if(!p_getc(&(temp_mapscr->flags2),f))
16889 return qe_invalid;
16890
1/2
✓ Branch 0 taken 433 times.
✗ Branch 1 not taken.
433 if(!p_getc(&(temp_mapscr->flags3),f))
16891 return qe_invalid;
16892
1/2
✓ Branch 0 taken 433 times.
✗ Branch 1 not taken.
433 if(!p_getc(&(temp_mapscr->flags4),f))
16893 return qe_invalid;
16894
1/2
✓ Branch 0 taken 433 times.
✗ Branch 1 not taken.
433 if(!p_getc(&(temp_mapscr->flags5),f))
16895 return qe_invalid;
16896
1/2
✓ Branch 0 taken 433 times.
✗ Branch 1 not taken.
433 if(!p_getc(&(temp_mapscr->flags6),f))
16897 return qe_invalid;
16898
1/2
✓ Branch 0 taken 433 times.
✗ Branch 1 not taken.
433 if(!p_getc(&(temp_mapscr->flags7),f))
16899 return qe_invalid;
16900
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 433 times.
433 if(!p_getc(&(temp_mapscr->flags8),f))
16901 return qe_invalid;
16902
1/2
✓ Branch 0 taken 433 times.
✗ Branch 1 not taken.
433 if(!p_getc(&(temp_mapscr->flags9),f))
16903 return qe_invalid;
16904
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 433 times.
433 if(!p_getc(&(temp_mapscr->flags10),f))
16905 return qe_invalid;
16906
1/2
✓ Branch 0 taken 433 times.
✗ Branch 1 not taken.
433 if(!p_getc(&(temp_mapscr->enemyflags),f))
16907 return qe_invalid;
16908 433 }
16909
2/2
✓ Branch 0 taken 5660 times.
✓ Branch 1 taken 377 times.
6037 if(scr_has_flags & SCRHAS_ENEMY)
16910 {
16911
2/2
✓ Branch 0 taken 3770 times.
✓ Branch 1 taken 377 times.
4147 for(int32_t k=0; k<10; k++)
16912 {
16913
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3770 times.
3770 if(!p_igetw(&(temp_mapscr->enemy[k]),f))
16914 return qe_invalid;
16915
1/2
✓ Branch 0 taken 3770 times.
✗ Branch 1 not taken.
3770 if (unsigned(temp_mapscr->enemy[k]) > MAXGUYS)
16916 temp_mapscr->enemy[k] = 0;
16917 3770 }
16918
1/2
✓ Branch 0 taken 377 times.
✗ Branch 1 not taken.
377 if(!p_getc(&(temp_mapscr->pattern),f))
16919 return qe_invalid;
16920 377 }
16921
2/2
✓ Branch 0 taken 6004 times.
✓ Branch 1 taken 33 times.
6037 if(scr_has_flags & SCRHAS_CARRY)
16922 {
16923
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 33 times.
33 if(!p_igetw(&(temp_mapscr->noreset),f))
16924 return qe_invalid;
16925
1/2
✓ Branch 0 taken 33 times.
✗ Branch 1 not taken.
33 if(!p_igetw(&(temp_mapscr->nocarry),f))
16926 return qe_invalid;
16927
1/2
✓ Branch 0 taken 33 times.
✗ Branch 1 not taken.
33 if(!p_getc(&(temp_mapscr->nextmap),f))
16928 return qe_invalid;
16929
1/2
✓ Branch 0 taken 33 times.
✗ Branch 1 not taken.
33 if(!p_getc(&(temp_mapscr->nextscr),f))
16930 return qe_invalid;
16931 33 }
16932
2/2
✓ Branch 0 taken 5970 times.
✓ Branch 1 taken 67 times.
6037 if(scr_has_flags & SCRHAS_SCRIPT)
16933 {
16934
1/2
✓ Branch 0 taken 67 times.
✗ Branch 1 not taken.
67 if(!p_igetw(&(temp_mapscr->script),f))
16935 return qe_invalid;
16936
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 67 times.
67 if(!p_getc(&(temp_mapscr->preloadscript),f))
16937 return qe_invalid;
16938
2/2
✓ Branch 0 taken 536 times.
✓ Branch 1 taken 67 times.
603 for ( int32_t q = 0; q < 8; q++ )
16939 {
16940
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 536 times.
536 if(!p_igetl(&(temp_mapscr->screeninitd[q]),f))
16941 return qe_invalid;
16942 536 }
16943 67 }
16944
1/2
✓ Branch 0 taken 6037 times.
✗ Branch 1 not taken.
6037 if(scr_has_flags & SCRHAS_UNUSED)
16945 {
16946 for ( int32_t q = 0; q < 10; q++ )
16947 {
16948 if(!p_igetl(&(temp_mapscr->npcstrings[q]),f))
16949 return qe_invalid;
16950 }
16951 for ( int32_t q = 0; q < 10; q++ )
16952 {
16953 if(!p_igetw(&(temp_mapscr->new_items[q]),f))
16954 return qe_invalid;
16955 }
16956 for ( int32_t q = 0; q < 10; q++ )
16957 {
16958 if(!p_igetw(&(temp_mapscr->new_item_x[q]),f))
16959 return qe_invalid;
16960 }
16961 for ( int32_t q = 0; q < 10; q++ )
16962 {
16963 if(!p_igetw(&(temp_mapscr->new_item_y[q]),f))
16964 return qe_invalid;
16965 }
16966 }
16967
2/2
✓ Branch 0 taken 5620 times.
✓ Branch 1 taken 417 times.
6037 if(scr_has_flags & SCRHAS_SECRETS)
16968 {
16969
2/2
✓ Branch 0 taken 53376 times.
✓ Branch 1 taken 417 times.
53793 for(int32_t k=0; k<128; k++)
16970 {
16971
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 53376 times.
53376 if(!p_igetw(&(temp_mapscr->secretcombo[k]),f))
16972 return qe_invalid;
16973 53376 }
16974
2/2
✓ Branch 0 taken 53376 times.
✓ Branch 1 taken 417 times.
53793 for(int32_t k=0; k<128; k++)
16975 {
16976
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 53376 times.
53376 if(!p_getc(&(temp_mapscr->secretcset[k]),f))
16977 return qe_invalid;
16978 53376 }
16979
2/2
✓ Branch 0 taken 53376 times.
✓ Branch 1 taken 417 times.
53793 for(int32_t k=0; k<128; k++)
16980 {
16981
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 53376 times.
53376 if(!p_getc(&(temp_mapscr->secretflag[k]),f))
16982 return qe_invalid;
16983 53376 }
16984 417 }
16985
2/2
✓ Branch 0 taken 2945 times.
✓ Branch 1 taken 3092 times.
6037 if(scr_has_flags & SCRHAS_COMBOFLAG)
16986 {
16987
2/2
✓ Branch 0 taken 544192 times.
✓ Branch 1 taken 3092 times.
547284 for(int32_t k=0; k<176; ++k)
16988 {
16989
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 544192 times.
544192 if(!p_igetw(&(temp_mapscr->data[k]),f))
16990 return qe_invalid;
16991 544192 }
16992
2/2
✓ Branch 0 taken 544192 times.
✓ Branch 1 taken 3092 times.
547284 for(int32_t k=0; k<176; ++k)
16993 {
16994
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 544192 times.
544192 if(!p_getc(&(temp_mapscr->sflag[k]),f))
16995 return qe_invalid;
16996 544192 }
16997
2/2
✓ Branch 0 taken 544192 times.
✓ Branch 1 taken 3092 times.
547284 for(int32_t k=0; k<176; ++k)
16998 {
16999
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 544192 times.
544192 if(!p_getc(&(temp_mapscr->cset[k]),f))
17000 return qe_invalid;
17001 544192 }
17002 3092 }
17003
1/2
✓ Branch 0 taken 6037 times.
✗ Branch 1 not taken.
6037 if(scr_has_flags & SCRHAS_MISC)
17004 {
17005
1/2
✓ Branch 0 taken 6037 times.
✗ Branch 1 not taken.
6037 if(!p_igetw(&(temp_mapscr->color),f))
17006 return qe_invalid;
17007
1/2
✓ Branch 0 taken 6037 times.
✗ Branch 1 not taken.
6037 if(!p_getc(&(temp_mapscr->csensitive),f))
17008 return qe_invalid;
17009
1/2
✓ Branch 0 taken 6037 times.
✗ Branch 1 not taken.
6037 if(!p_getc(&(temp_mapscr->oceansfx),f))
17010 return qe_invalid;
17011
1/2
✓ Branch 0 taken 6037 times.
✗ Branch 1 not taken.
6037 if(!p_getc(&(temp_mapscr->bosssfx),f))
17012 return qe_invalid;
17013
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6037 times.
6037 if(!p_getc(&(temp_mapscr->secretsfx),f))
17014 return qe_invalid;
17015
1/2
✓ Branch 0 taken 6037 times.
✗ Branch 1 not taken.
6037 if(!p_getc(&(temp_mapscr->holdupsfx),f))
17016 return qe_invalid;
17017
1/2
✓ Branch 0 taken 6037 times.
✗ Branch 1 not taken.
6037 if(!p_igetw(&(temp_mapscr->timedwarptics),f))
17018 return qe_invalid;
17019
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6037 times.
6037 if(!p_igetw(&(temp_mapscr->screen_midi),f))
17020 return qe_invalid;
17021
1/2
✓ Branch 0 taken 6037 times.
✗ Branch 1 not taken.
6037 if(!p_getc(&(temp_mapscr->lens_layer),f))
17022 return qe_invalid;
17023
2/2
✓ Branch 0 taken 5301 times.
✓ Branch 1 taken 736 times.
6037 if(version > 27)
17024 {
17025
1/2
✓ Branch 0 taken 736 times.
✗ Branch 1 not taken.
736 if(!p_getc(&(temp_mapscr->lens_show),f))
17026 return qe_invalid;
17027
1/2
✓ Branch 0 taken 736 times.
✗ Branch 1 not taken.
736 if(!p_getc(&(temp_mapscr->lens_hide),f))
17028 return qe_invalid;
17029 736 }
17030 6037 }
17031 else
17032 {
17033 temp_mapscr->screen_midi = -1;
17034 temp_mapscr->csensitive = 1;
17035 }
17036 //FFC
17037 6037 bool old_ff = version < 25;
17038 6037 dword bits = 0;
17039 6037 word numffc = 32;
17040
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6037 times.
6037 if(old_ff)
17041 {
17042 if(!p_igetl(&bits,f))
17043 return qe_invalid;
17044 }
17045 else
17046 {
17047
1/2
✓ Branch 0 taken 6037 times.
✗ Branch 1 not taken.
6037 if(!p_igetw(&numffc,f))
17048 return qe_invalid;
17049 }
17050 byte tempbyte;
17051 word tempw;
17052
4/6
✓ Branch 0 taken 31 times.
✓ Branch 1 taken 6006 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 31 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 31 times.
6037 static ffcdata nil_ffc;
17053 6037 temp_mapscr->ffcCountMarkDirty();
17054
2/2
✓ Branch 0 taken 6037 times.
✓ Branch 1 taken 8259 times.
14296 for(word m = 0; m < numffc; ++m)
17055 {
17056
1/2
✓ Branch 0 taken 8259 times.
✗ Branch 1 not taken.
8259 ffcdata& tempffc = (m < MAXFFCS)
17057 8259 ? temp_mapscr->ffcs[m]
17058 : nil_ffc; //sanity
17059 8259 tempffc.clear();
17060
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 8259 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
8259 if(old_ff && !(bits & (1<<m))) continue;
17061
17062
1/2
✓ Branch 0 taken 8259 times.
✗ Branch 1 not taken.
8259 if(!p_igetw(&tempw,f))
17063 return qe_invalid;
17064
3/4
✓ Branch 0 taken 8259 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1517 times.
✓ Branch 3 taken 6742 times.
8259 if(!old_ff && !tempw) //empty ffc, nothing more to load
17065 6742 continue;
17066 1517 tempffc.data = tempw;
17067
17068
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1517 times.
1517 if(!p_getc(&(tempffc.cset),f))
17069 return qe_invalid;
17070
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1517 times.
1517 if(!p_igetw(&(tempffc.delay),f))
17071 return qe_invalid;
17072
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1517 times.
1517 if(!p_igetzf(&(tempffc.x),f))
17073 return qe_invalid;
17074
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1517 times.
1517 if(!p_igetzf(&(tempffc.y),f))
17075 return qe_invalid;
17076
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1517 times.
1517 if(!p_igetzf(&(tempffc.vx),f))
17077 return qe_invalid;
17078
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1517 times.
1517 if(!p_igetzf(&(tempffc.vy),f))
17079 return qe_invalid;
17080
1/2
✓ Branch 0 taken 1517 times.
✗ Branch 1 not taken.
1517 if(!p_igetzf(&(tempffc.ax),f))
17081 return qe_invalid;
17082
1/2
✓ Branch 0 taken 1517 times.
✗ Branch 1 not taken.
1517 if(!p_igetzf(&(tempffc.ay),f))
17083 return qe_invalid;
17084
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1517 times.
1517 if(!p_getc(&(tempffc.link),f))
17085 return qe_invalid;
17086
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1517 times.
1517 if(version < 24)
17087 {
17088 if(!p_getc(&tempbyte,f))
17089 return qe_invalid;
17090 tempffc.hit_width = (tempbyte&0x3F)+1;
17091 tempffc.txsz = (tempbyte>>6)+1;
17092 if(!p_getc(&tempbyte,f))
17093 return qe_invalid;
17094 tempffc.hit_height = (tempbyte&0x3F)+1;
17095 tempffc.tysz = (tempbyte>>6)+1;
17096 }
17097 else
17098 {
17099
1/2
✓ Branch 0 taken 1517 times.
✗ Branch 1 not taken.
1517 if(!p_igetl(&(tempffc.hit_width),f))
17100 return qe_invalid;
17101
1/2
✓ Branch 0 taken 1517 times.
✗ Branch 1 not taken.
1517 if(!p_igetl(&(tempffc.hit_height),f))
17102 return qe_invalid;
17103
1/2
✓ Branch 0 taken 1517 times.
✗ Branch 1 not taken.
1517 if(!p_getc(&(tempffc.txsz),f))
17104 return qe_invalid;
17105
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1517 times.
1517 if(!p_getc(&(tempffc.tysz),f))
17106 return qe_invalid;
17107 }
17108
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1517 times.
1517 if(!p_igetl(&(tempffc.flags),f))
17109 return qe_invalid;
17110 1517 tempffc.updateSolid();
17111
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1517 times.
1517 if(!p_igetw(&(tempffc.script),f))
17112 return qe_invalid;
17113
2/2
✓ Branch 0 taken 12136 times.
✓ Branch 1 taken 1517 times.
13653 for(auto q = 0; q < 8; ++q)
17114 {
17115
1/2
✓ Branch 0 taken 12136 times.
✗ Branch 1 not taken.
12136 if(!p_igetl(&(tempffc.initd[q]),f))
17116 return qe_invalid;
17117 12136 }
17118
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1517 times.
1517 if(!p_getc(&(tempbyte),f))
17119 return qe_invalid;
17120 1517 tempffc.inita[0]=tempbyte*10000;
17121
17122
1/2
✓ Branch 0 taken 1517 times.
✗ Branch 1 not taken.
1517 if(!p_getc(&(tempbyte),f))
17123 return qe_invalid;
17124 1517 tempffc.inita[1]=tempbyte*10000;
17125
17126
1/2
✓ Branch 0 taken 1517 times.
✗ Branch 1 not taken.
1517 if(loading_tileset_flags & TILESET_CLEARSCRIPTS)
17127 {
17128 tempffc.script = 0;
17129 for(int q = 0; q < 8; ++q)
17130 tempffc.initd[q] = 0;
17131 }
17132 1517 }
17133
2/2
✓ Branch 0 taken 764477 times.
✓ Branch 1 taken 6037 times.
770514 for(word m = numffc; m < MAXFFCS; ++m)
17134 {
17135 764477 temp_mapscr->ffcs[m].clear();
17136 764477 }
17137 //END FFC
17138 }
17139 253213 return 0;
17140 263360 }
17141
17142
17143 128 int32_t readmaps(PACKFILE *f, zquestheader *Header)
17144 {
17145
2/2
✓ Branch 0 taken 124 times.
✓ Branch 1 taken 4 times.
128 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_maps);
17146 128 int32_t scr=0;
17147
17148 128 word version=0;
17149 dword dummy;
17150 int32_t screens_to_read;
17151
17152 128 mapscr temp_mapscr;
17153 word temp_map_count;
17154 dword section_size;
17155
17156
3/6
✓ Branch 0 taken 124 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 124 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
128 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<137)))
17157 {
17158 4 screens_to_read=MAPSCRS192b136;
17159 4 }
17160 else
17161 {
17162 124 screens_to_read=MAPSCRS;
17163 }
17164
17165
2/2
✓ Branch 0 taken 124 times.
✓ Branch 1 taken 4 times.
128 if(Header->zelda_version > 0x192)
17166 {
17167 //section version info
17168
1/2
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
124 if(!p_igetw(&version,f))
17169 {
17170 return qe_invalid;
17171 }
17172
17173 124 FFCore.quest_format[vMaps] = version;
17174
17175 //al_trace("Maps version %d\n", version);
17176
1/2
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
124 if(!p_igetw(&dummy,f))
17177 {
17178 return qe_invalid;
17179 }
17180
17181 //section size
17182
1/2
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
124 if(!p_igetl(&section_size,f))
17183 {
17184 return qe_invalid;
17185 }
17186
17187 //finally... section data
17188
1/2
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
124 if(!p_igetw(&temp_map_count,f))
17189 {
17190 return 5;
17191 }
17192 124 }
17193 else
17194 {
17195 4 temp_map_count=map_count;
17196 }
17197
17198
2/4
✓ Branch 0 taken 128 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 128 times.
128 if (!(temp_map_count >= 0 && temp_map_count <= MAXMAPS))
17199 {
17200 return qe_invalid;
17201 }
17202
17203
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 128 times.
128 if (!should_skip)
17204 {
17205 128 const int32_t _mapsSize = MAPSCRS*temp_map_count;
17206 128 TheMaps.resize(_mapsSize);
17207 128 map_autolayers.clear();
17208 128 map_autolayers.resize(temp_map_count*6);
17209
2/2
✓ Branch 0 taken 264520 times.
✓ Branch 1 taken 128 times.
264648 for(int32_t i(0); i<_mapsSize; i++)
17210 264520 TheMaps[i].zero_memory();
17211 128 }
17212
17213 128 temp_mapscr.zero_memory();
17214
17215
4/4
✓ Branch 0 taken 128 times.
✓ Branch 1 taken 1945 times.
✓ Branch 2 taken 1945 times.
✓ Branch 3 taken 128 times.
2073 for(int32_t i=0; i<temp_map_count && i<MAXMAPS; i++)
17216 {
17217 1945 byte valid=1;
17218
2/2
✓ Branch 0 taken 1819 times.
✓ Branch 1 taken 126 times.
1945 if(version > 22)
17219 {
17220
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 126 times.
126 if(!p_getc(&valid,f))
17221 return qe_invalid;
17222 126 }
17223
4/4
✓ Branch 0 taken 1938 times.
✓ Branch 1 taken 7 times.
✓ Branch 2 taken 1886 times.
✓ Branch 3 taken 52 times.
1945 if(valid && version > 25)
17224 {
17225
2/2
✓ Branch 0 taken 312 times.
✓ Branch 1 taken 52 times.
364 for(int q = 0; q < 6; ++q)
17226 {
17227
1/2
✓ Branch 0 taken 312 times.
✗ Branch 1 not taken.
312 if(!p_igetw(&map_autolayers[i*6+q],f))
17228 return qe_invalid;
17229 312 }
17230 52 }
17231
2/2
✓ Branch 0 taken 264312 times.
✓ Branch 1 taken 1945 times.
266257 for(int32_t j=0; j<screens_to_read; j++)
17232 {
17233 264312 scr=i*MAPSCRS+j;
17234 264312 clear_screen(&temp_mapscr);
17235
2/2
✓ Branch 0 taken 952 times.
✓ Branch 1 taken 263360 times.
264312 if(valid)
17236 263360 readmapscreen(f, Header, &temp_mapscr, version, scr);
17237
17238
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 264312 times.
264312 if (!should_skip)
17239 264312 TheMaps[scr] = temp_mapscr;
17240 264312 }
17241
17242
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1945 times.
1945 if (should_skip)
17243 continue;
17244
17245
3/6
✓ Branch 0 taken 1893 times.
✓ Branch 1 taken 52 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1893 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1945 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<137)))
17246 {
17247 52 int32_t index = (i*MAPSCRS+132);
17248
17249 52 TheMaps[index]=TheMaps[index-1];
17250
17251 52 MEMCPY_ARR(TheMaps[i*MAPSCRS+132].data, TheMaps[i*MAPSCRS+131].data);
17252 52 MEMCPY_ARR(TheMaps[i*MAPSCRS+132].sflag, TheMaps[i*MAPSCRS+131].sflag);
17253 52 MEMCPY_ARR(TheMaps[i*MAPSCRS+132].cset, TheMaps[i*MAPSCRS+131].cset);
17254
17255
2/2
✓ Branch 0 taken 156 times.
✓ Branch 1 taken 52 times.
208 for(int32_t j=133; j<MAPSCRS; j++)
17256 {
17257 156 scr=i*MAPSCRS+j;
17258
17259 156 TheMaps[scr].zero_memory();
17260 156 TheMaps[scr].valid = mVERSION;
17261 156 TheMaps[scr].screen_midi = -1;
17262 156 TheMaps[scr].csensitive = 1;
17263 156 }
17264 52 }
17265
17266
3/6
✓ Branch 0 taken 1893 times.
✓ Branch 1 taken 52 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1893 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1945 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<154)))
17267 {
17268
2/2
✓ Branch 0 taken 7072 times.
✓ Branch 1 taken 52 times.
7124 for(int32_t j=0; j<MAPSCRS; j++)
17269 {
17270 7072 scr=i*MAPSCRS+j;
17271 7072 TheMaps[scr].door_combo_set=MakeDoors(i, j);
17272
17273
2/2
✓ Branch 0 taken 905216 times.
✓ Branch 1 taken 7072 times.
912288 for(int32_t k=0; k<128; k++)
17274 {
17275 905216 TheMaps[scr].secretcset[k]=tcmbcset2(i, TheMaps[scr].secretcombo[k]);
17276 905216 TheMaps[scr].secretflag[k]=tcmbflag2(i, TheMaps[scr].secretcombo[k]);
17277 905216 TheMaps[scr].secretcombo[k]=tcmbdat2(i, j, TheMaps[scr].secretcombo[k]);
17278 905216 }
17279 7072 }
17280 52 }
17281 1945 }
17282 128 map_count = temp_map_count;
17283 128 clear_screen(&temp_mapscr);
17284 128 return 0;
17285 128 }
17286
17287
17288 1089313 void update_combo(newcombo& cmb, word section_version)
17289 {
17290
2/2
✓ Branch 0 taken 148596 times.
✓ Branch 1 taken 940717 times.
1089313 if(section_version < 40)
17291 {
17292
3/3
✓ Branch 0 taken 1389 times.
✓ Branch 1 taken 14209 times.
✓ Branch 2 taken 925119 times.
940717 switch(cmb.type)
17293 {
17294 case cWATER: case cSHALLOWWATER:
17295 14209 cmb.attribytes[6] = iwRipples;
17296 14209 break;
17297 case cTALLGRASS: case cTALLGRASSNEXT: case cTALLGRASSTOUCHY:
17298 1389 cmb.attribytes[6] = iwTallGrass;
17299 1389 break;
17300 }
17301 940717 }
17302 1089313 }
17303 95 int32_t readcombos_old(word section_version, PACKFILE *f, zquestheader *, word version, word build, word start_combo, word max_combos)
17304 {
17305
2/2
✓ Branch 0 taken 91 times.
✓ Branch 1 taken 4 times.
95 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_combos);
17306
17307
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 95 times.
95 if (!should_skip)
17308 {
17309 95 reset_combo_animations();
17310 95 reset_combo_animations2();
17311 95 init_combo_classes();
17312 95 }
17313
17314 // combos
17315 95 word combos_used=0;
17316 int32_t dummy;
17317 byte padding;
17318 95 newcombo temp_combo;
17319 //word section_cversion=0;
17320
17321
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 95 times.
95 if (!should_skip)
17322
2/2
✓ Branch 0 taken 6201600 times.
✓ Branch 1 taken 95 times.
6201695 for(int32_t q = start_combo; q < start_combo+max_combos; ++q)
17323
1/2
✓ Branch 0 taken 6201600 times.
✗ Branch 1 not taken.
6201695 combobuf[q].clear();
17324
17325 // if(version > 0x192)
17326 // {
17327 // //section version info
17328 // if(!p_igetw(&section_version,f))
17329 // {
17330 // return qe_invalid;
17331 // }
17332
17333 // FFCore.quest_format[vCombos] = section_version;
17334
17335 // //al_trace("Combos version %d\n", section_version);
17336 // if(!p_igetw(&section_cversion,f))
17337 // {
17338 // return qe_invalid;
17339 // }
17340
17341 // //section size
17342 // if(!p_igetl(&dummy,f))
17343 // {
17344 // return qe_invalid;
17345 // }
17346 // }
17347
17348
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 95 times.
95 if(version < 0x174)
17349 {
17350 combos_used=1024;
17351 }
17352
2/2
✓ Branch 0 taken 91 times.
✓ Branch 1 taken 4 times.
95 else if(version < 0x191)
17353 {
17354 4 combos_used=2048;
17355 4 }
17356 else
17357 {
17358
2/4
✓ Branch 0 taken 91 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 91 times.
✗ Branch 3 not taken.
91 if(!p_igetw(&combos_used,f))
17359 {
17360 return qe_invalid;
17361 }
17362 }
17363
17364 //finally... section data
17365
2/2
✓ Branch 0 taken 873209 times.
✓ Branch 1 taken 95 times.
873304 for(int32_t i=0; i<combos_used; i++)
17366 {
17367
1/2
✓ Branch 0 taken 873209 times.
✗ Branch 1 not taken.
873209 temp_combo.clear();
17368
17369
2/2
✓ Branch 0 taken 68884 times.
✓ Branch 1 taken 804325 times.
873209 if ( section_version >= 11 )
17370 {
17371
2/4
✓ Branch 0 taken 68884 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 68884 times.
✗ Branch 3 not taken.
68884 if(!p_igetl(&temp_combo.tile,f))
17372 {
17373 return qe_invalid;
17374 }
17375 68884 }
17376 else
17377 {
17378
2/4
✓ Branch 0 taken 804325 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 804325 times.
✗ Branch 3 not taken.
804325 if(!p_igetw(&temp_combo.tile,f))
17379 {
17380 return qe_invalid;
17381 }
17382 }
17383 873209 temp_combo.o_tile = temp_combo.tile;
17384
2/4
✓ Branch 0 taken 873209 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 873209 times.
✗ Branch 3 not taken.
873209 if(!p_getc(&temp_combo.flip,f))
17385 {
17386 return qe_invalid;
17387 }
17388
17389
2/4
✓ Branch 0 taken 873209 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 873209 times.
✗ Branch 3 not taken.
873209 if(!p_getc(&temp_combo.walk,f))
17390 {
17391 return qe_invalid;
17392 }
17393
17394
2/4
✓ Branch 0 taken 873209 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 873209 times.
✗ Branch 3 not taken.
873209 if(!p_getc(&temp_combo.type,f))
17395 {
17396 return qe_invalid;
17397 }
17398
17399
2/4
✓ Branch 0 taken 873209 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 873209 times.
✗ Branch 3 not taken.
873209 if(!p_getc(&temp_combo.csets,f))
17400 {
17401 return qe_invalid;
17402 }
17403
17404
2/2
✓ Branch 0 taken 8192 times.
✓ Branch 1 taken 865017 times.
873209 if(version < 0x193)
17405 {
17406
2/4
✓ Branch 0 taken 8192 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8192 times.
✗ Branch 3 not taken.
8192 if(!p_getc(&padding,f))
17407 return qe_invalid;
17408
17409
2/4
✓ Branch 0 taken 8192 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8192 times.
✗ Branch 3 not taken.
8192 if(!p_getc(&padding,f))
17410 return qe_invalid;
17411
17412
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8192 times.
8192 if(version < 0x192)
17413 {
17414
1/2
✓ Branch 0 taken 8192 times.
✗ Branch 1 not taken.
8192 if(version == 0x191)
17415 {
17416 for(int32_t tmpcounter=0; tmpcounter<16; tmpcounter++)
17417 {
17418 if(!p_getc(&padding,f))
17419 return qe_invalid;
17420 }
17421 }
17422 8192 }
17423 8192 }
17424
2/2
✓ Branch 0 taken 865017 times.
✓ Branch 1 taken 8192 times.
873209 if(version >= 0x192)
17425 {
17426
2/4
✓ Branch 0 taken 865017 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 865017 times.
✗ Branch 3 not taken.
865017 if(!p_getc(&temp_combo.frames,f))
17427 return qe_invalid;
17428
17429
2/4
✓ Branch 0 taken 865017 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 865017 times.
✗ Branch 3 not taken.
865017 if(!p_getc(&temp_combo.speed,f))
17430 return qe_invalid;
17431
17432
2/4
✓ Branch 0 taken 865017 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 865017 times.
✗ Branch 3 not taken.
865017 if(!p_igetw(&temp_combo.nextcombo,f))
17433 return qe_invalid;
17434
17435
2/4
✓ Branch 0 taken 865017 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 865017 times.
✗ Branch 3 not taken.
865017 if(!p_getc(&temp_combo.nextcset,f))
17436 return qe_invalid;
17437
17438 //Base flag
17439
2/2
✓ Branch 0 taken 399183 times.
✓ Branch 1 taken 465834 times.
865017 if(section_version>=3)
17440
2/4
✓ Branch 0 taken 399183 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 399183 times.
✗ Branch 3 not taken.
399183 if(!p_getc(&temp_combo.flag,f))
17441 return qe_invalid;
17442
17443
2/2
✓ Branch 0 taken 399183 times.
✓ Branch 1 taken 465834 times.
865017 if(section_version>=4)
17444 {
17445
2/4
✓ Branch 0 taken 399183 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 399183 times.
✗ Branch 3 not taken.
399183 if(!p_getc(&temp_combo.skipanim,f))
17446 return qe_invalid;
17447
17448
2/4
✓ Branch 0 taken 399183 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 399183 times.
✗ Branch 3 not taken.
399183 if(!p_igetw(&temp_combo.nexttimer,f))
17449 return qe_invalid;
17450 399183 }
17451
17452
2/2
✓ Branch 0 taken 399183 times.
✓ Branch 1 taken 465834 times.
865017 if(section_version>=5)
17453
2/4
✓ Branch 0 taken 399183 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 399183 times.
✗ Branch 3 not taken.
399183 if(!p_getc(&temp_combo.skipanimy,f))
17454 return qe_invalid;
17455
17456
2/2
✓ Branch 0 taken 399183 times.
✓ Branch 1 taken 465834 times.
865017 if(section_version>=6)
17457 {
17458
2/4
✓ Branch 0 taken 399183 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 399183 times.
✗ Branch 3 not taken.
399183 if(!p_getc(&temp_combo.animflags,f))
17459 return qe_invalid;
17460
17461
1/2
✓ Branch 0 taken 399183 times.
✗ Branch 1 not taken.
399183 if(section_version == 6)
17462 temp_combo.animflags = temp_combo.animflags ? AF_FRESH : 0;
17463 399183 }
17464
17465
2/2
✓ Branch 0 taken 796133 times.
✓ Branch 1 taken 68884 times.
865017 if(section_version>=8) //combo Attributes[4] and userflags.
17466 {
17467
2/2
✓ Branch 0 taken 68884 times.
✓ Branch 1 taken 275536 times.
344420 for ( int32_t q = 0; q < NUM_COMBO_ATTRIBUTES; q++ )
17468
2/4
✓ Branch 0 taken 275536 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 275536 times.
✗ Branch 3 not taken.
275536 if(!p_igetl(&temp_combo.attributes[q],f))
17469 return qe_invalid;
17470
2/4
✓ Branch 0 taken 68884 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 68884 times.
✗ Branch 3 not taken.
68884 if(!p_igetl(&temp_combo.usrflags,f))
17471 return qe_invalid;
17472
1/2
✓ Branch 0 taken 68884 times.
✗ Branch 1 not taken.
68884 if(section_version >= 20)
17473
2/4
✓ Branch 0 taken 68884 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 68884 times.
✗ Branch 3 not taken.
68884 if(!p_igetw(&temp_combo.genflags,f))
17474 return qe_invalid;
17475 68884 }
17476
2/2
✓ Branch 0 taken 68884 times.
✓ Branch 1 taken 796133 times.
865017 if(section_version>=10) //combo trigger flags
17477 {
17478
2/2
✓ Branch 0 taken 206652 times.
✓ Branch 1 taken 68884 times.
275536 for ( int32_t q = 0; q < 3; q++ )
17479
2/4
✓ Branch 0 taken 206652 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 206652 times.
✗ Branch 3 not taken.
206652 if(!p_igetl(&temp_combo.triggerflags[q],f))
17480 return qe_invalid;
17481 68884 }
17482
1/2
✓ Branch 0 taken 796133 times.
✗ Branch 1 not taken.
796133 else if(section_version==9) //combo trigger flags, V9 only had two indices of triggerflags[]
17483 {
17484 for ( int32_t q = 0; q < 2; q++ )
17485 if(!p_igetl(&temp_combo.triggerflags[q],f))
17486 return qe_invalid;
17487 }
17488
2/2
✓ Branch 0 taken 68884 times.
✓ Branch 1 taken 796133 times.
865017 if(section_version >= 9)
17489
2/4
✓ Branch 0 taken 68884 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 68884 times.
✗ Branch 3 not taken.
68884 if(!p_igetl(&temp_combo.triggerlevel,f))
17490 return qe_invalid;
17491
2/2
✓ Branch 0 taken 68884 times.
✓ Branch 1 taken 796133 times.
865017 if(section_version >= 22)
17492
2/4
✓ Branch 0 taken 68884 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 68884 times.
✗ Branch 3 not taken.
68884 if(!p_getc(&temp_combo.triggerbtn,f))
17493 return qe_invalid;
17494
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 865017 times.
865017 if(section_version >= 24)
17495 {
17496 if(!p_getc(&temp_combo.triggeritem,f))
17497 return qe_invalid;
17498 if(!p_getc(&temp_combo.trigtimer,f))
17499 return qe_invalid;
17500 }
17501
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 865017 times.
865017 if(section_version >= 25)
17502 if(!p_getc(&temp_combo.trigsfx,f))
17503 return qe_invalid;
17504
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 865017 times.
865017 if(section_version >= 27)
17505 if(!p_igetl(&temp_combo.trigchange,f))
17506 return qe_invalid;
17507
17508
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 865017 times.
865017 if(section_version >= 29)
17509 {
17510 if(!p_igetw(&temp_combo.trigprox,f))
17511 return qe_invalid;
17512 if(!p_getc(&temp_combo.trigctr,f))
17513 return qe_invalid;
17514 if(!p_igetl(&temp_combo.trigctramnt,f))
17515 return qe_invalid;
17516 }
17517
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 865017 times.
865017 if(section_version >= 30)
17518 if(!p_getc(&temp_combo.triglbeam,f))
17519 return qe_invalid;
17520
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 865017 times.
865017 if(section_version >= 31)
17521 {
17522 if(!p_getc(&temp_combo.trigcschange,f))
17523 return qe_invalid;
17524 if(!p_igetw(&temp_combo.spawnitem,f))
17525 return qe_invalid;
17526 if(!p_igetw(&temp_combo.spawnenemy,f))
17527 return qe_invalid;
17528 if(!p_getc(&temp_combo.exstate,f))
17529 return qe_invalid;
17530 if(!p_igetl(&temp_combo.spawnip,f))
17531 return qe_invalid;
17532 if(!p_getc(&temp_combo.trigcopycat,f))
17533 return qe_invalid;
17534 }
17535
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 865017 times.
865017 if(section_version >= 32)
17536 if(!p_getc(&temp_combo.trigcooldown,f))
17537 return qe_invalid;
17538
17539
2/2
✓ Branch 0 taken 796133 times.
✓ Branch 1 taken 68884 times.
865017 if(section_version>=12) //combo label
17540 {
17541 char label[12];
17542 68884 label[11] = '\0';
17543
2/2
✓ Branch 0 taken 68884 times.
✓ Branch 1 taken 757724 times.
826608 for ( int32_t q = 0; q < 11; q++ )
17544
2/4
✓ Branch 0 taken 757724 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 757724 times.
✗ Branch 3 not taken.
757724 if(!p_getc(&label[q],f))
17545 return qe_invalid;
17546
1/2
✓ Branch 0 taken 68884 times.
✗ Branch 1 not taken.
68884 temp_combo.label = label;
17547 68884 }
17548
2/2
✓ Branch 0 taken 796133 times.
✓ Branch 1 taken 68884 times.
865017 if(section_version>=13) //attribytes[4]
17549
2/2
✓ Branch 0 taken 275536 times.
✓ Branch 1 taken 68884 times.
344420 for ( int32_t q = 0; q < 4; q++ )
17550
2/4
✓ Branch 0 taken 275536 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 275536 times.
✗ Branch 3 not taken.
275536 if(!p_getc(&temp_combo.attribytes[q],f))
17551 68884 return qe_invalid;
17552 /* HIGHLY UNORTHODOX UPDATING THING, by Deedee
17553 * This fixes a poor implementation of a ->next flag bug thing.
17554 * Zoria didn't bump up the versions as liberally as he should have, but thankfully
17555 * there was a version bump a few weeks before a change that broke stuff.
17556 */
17557
3/4
✓ Branch 0 taken 68884 times.
✓ Branch 1 taken 796133 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 68884 times.
865017 if (section_version >= 13 && section_version < 21)
17558 {
17559 set_qr(qr_BUGGY_BUGGY_SLASH_TRIGGERS,1);
17560 }
17561 //combo scripts
17562
2/2
✓ Branch 0 taken 68884 times.
✓ Branch 1 taken 796133 times.
865017 if(section_version>=14)
17563 {
17564
2/4
✓ Branch 0 taken 68884 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 68884 times.
✗ Branch 3 not taken.
68884 if(!p_igetw(&temp_combo.script,f))
17565 return qe_invalid;
17566
2/2
✓ Branch 0 taken 137768 times.
✓ Branch 1 taken 68884 times.
206652 for ( int32_t q = 0; q < 2; q++ )
17567
2/4
✓ Branch 0 taken 137768 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 137768 times.
✗ Branch 3 not taken.
137768 if(!p_igetl(&temp_combo.initd[q],f))
17568 return qe_invalid;
17569 68884 }
17570 //al_trace("Read combo script data\n");
17571
2/2
✓ Branch 0 taken 68884 times.
✓ Branch 1 taken 796133 times.
865017 if(section_version>=15)
17572 {
17573
2/4
✓ Branch 0 taken 68884 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 68884 times.
✗ Branch 3 not taken.
68884 if(!p_igetl(&temp_combo.o_tile,f)) return qe_invalid;
17574
2/2
✓ Branch 0 taken 37028 times.
✓ Branch 1 taken 31856 times.
68884 if(!temp_combo.o_tile) temp_combo.o_tile = temp_combo.tile;
17575
2/4
✓ Branch 0 taken 68884 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 68884 times.
✗ Branch 3 not taken.
68884 if(!p_getc(&temp_combo.cur_frame,f)) return qe_invalid;
17576
2/4
✓ Branch 0 taken 68884 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 68884 times.
✗ Branch 3 not taken.
68884 if(!p_getc(&temp_combo.aclk,f)) return qe_invalid;
17577 68884 }
17578
2/2
✓ Branch 0 taken 796133 times.
✓ Branch 1 taken 68884 times.
865017 if(section_version>=17) //attribytes[4]
17579 {
17580
2/2
✓ Branch 0 taken 275536 times.
✓ Branch 1 taken 68884 times.
344420 for ( int32_t q = 4; q < 8; q++ ) //bump up attribytes...
17581
2/4
✓ Branch 0 taken 275536 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 275536 times.
✗ Branch 3 not taken.
275536 if(!p_getc(&temp_combo.attribytes[q],f))
17582 return qe_invalid;
17583
2/2
✓ Branch 0 taken 551072 times.
✓ Branch 1 taken 68884 times.
619956 for ( int32_t q = 0; q < 8; q++ ) //...and add attrishorts
17584
2/4
✓ Branch 0 taken 551072 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 551072 times.
✗ Branch 3 not taken.
551072 if(!p_igetw(&temp_combo.attrishorts[q],f))
17585 return qe_invalid;
17586 68884 }
17587
17588
1/2
✓ Branch 0 taken 865017 times.
✗ Branch 1 not taken.
865017 if(version < 0x193)
17589 for(int32_t q=0; q<11; q++)
17590 if(!p_getc(&dummy,f))
17591 return qe_invalid;
17592 865017 }
17593
17594 //Goriya tiles were flipped around in 2.11 build 7. Compensate for the flip here. -DD
17595
3/6
✓ Branch 0 taken 399183 times.
✓ Branch 1 taken 474026 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 399183 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
873209 if((version < 0x211)||((version == 0x211)&&(build<7)))
17596 {
17597
3/4
✓ Branch 0 taken 474026 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 465834 times.
✓ Branch 3 taken 8192 times.
474026 if(!get_qr(qr_NEWENEMYTILES))
17598 {
17599
1/5
✓ Branch 0 taken 8192 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
8192 switch(temp_combo.tile)
17600 {
17601 case 130:
17602 temp_combo.tile = 132;
17603 break;
17604
17605 case 131:
17606 temp_combo.tile = 133;
17607 break;
17608
17609 case 132:
17610 temp_combo.tile = 130;
17611 break;
17612
17613 case 133:
17614 temp_combo.tile = 131;
17615 break;
17616 }
17617 8192 }
17618 474026 }
17619
17620
2/2
✓ Branch 0 taken 68884 times.
✓ Branch 1 taken 804325 times.
873209 if(section_version < 15)
17621 804325 temp_combo.o_tile = temp_combo.tile;
17622
17623
2/2
✓ Branch 0 taken 68884 times.
✓ Branch 1 taken 804325 times.
873209 if(section_version<18) //upper bits for .walk
17624 804325 temp_combo.walk |= 0xF0;
17625
17626
2/2
✓ Branch 0 taken 68884 times.
✓ Branch 1 taken 804325 times.
873209 if(section_version < 19)
17627
2/2
✓ Branch 0 taken 3217300 times.
✓ Branch 1 taken 804325 times.
4021625 for(int32_t q = 0; q < 4; ++q)
17628 4021625 temp_combo.attributes[q] *= 10000L;
17629
17630
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 873209 times.
873209 if(section_version < 23)
17631 {
17632
2/2
✓ Branch 0 taken 384 times.
✓ Branch 1 taken 872825 times.
873209 switch(temp_combo.type) //combotriggerCMBTYPEFX now required for combotype-specific effects
17633 {
17634 case cSCRIPT1: case cSCRIPT2: case cSCRIPT3: case cSCRIPT4: case cSCRIPT5:
17635 case cSCRIPT6: case cSCRIPT7: case cSCRIPT8: case cSCRIPT9: case cSCRIPT10:
17636 case cTRIGGERGENERIC: case cCSWITCH:
17637 384 temp_combo.triggerflags[0] |= combotriggerCMBTYPEFX;
17638 384 }
17639 873209 }
17640
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 873209 times.
873209 if(section_version < 25)
17641 {
17642
2/2
✓ Branch 0 taken 3061 times.
✓ Branch 1 taken 870148 times.
873209 switch(temp_combo.type)
17643 {
17644 case cLOCKBLOCK: case cBOSSLOCKBLOCK:
17645
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3061 times.
3061 if(!(temp_combo.usrflags & cflag3))
17646 3061 temp_combo.attribytes[3] = WAV_DOOR;
17647 3061 temp_combo.usrflags &= ~cflag3;
17648 3061 break;
17649 }
17650 873209 }
17651
17652
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 873209 times.
873209 if(section_version < 26)
17653
2/2
✓ Branch 0 taken 872622 times.
✓ Branch 1 taken 587 times.
873796 if(temp_combo.type == cARMOS)
17654
1/2
✓ Branch 0 taken 587 times.
✗ Branch 1 not taken.
587 if(temp_combo.usrflags & cflag1)
17655 temp_combo.usrflags |= cflag3;
17656
17657
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 873209 times.
873209 if(section_version < 27)
17658 {
17659
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 873209 times.
873209 if(temp_combo.triggerflags[0] & 0x00040000) //'next'
17660 temp_combo.trigchange = 1;
17661
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 873209 times.
873209 else if(temp_combo.triggerflags[0] & 0x00080000) //'prev'
17662 temp_combo.trigchange = -1;
17663 873209 else temp_combo.trigchange = 0;
17664 873209 temp_combo.triggerflags[0] &= ~(0x00040000|0x00080000);
17665 873209 }
17666
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 873209 times.
873209 if(section_version < 28)
17667 {
17668
2/2
✓ Branch 0 taken 1689 times.
✓ Branch 1 taken 871520 times.
873209 switch(temp_combo.type)
17669 {
17670 case cLOCKBLOCK: case cLOCKEDCHEST:
17671
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1689 times.
1689 if(temp_combo.usrflags & cflag7)
17672 temp_combo.usrflags |= cflag8;
17673 1689 else temp_combo.usrflags &= ~cflag8;
17674 1689 temp_combo.usrflags &= ~cflag7;
17675 1689 break;
17676 }
17677
2/2
✓ Branch 0 taken 69 times.
✓ Branch 1 taken 873140 times.
873209 switch(temp_combo.type)
17678 {
17679 case cCHEST: case cLOCKEDCHEST: case cBOSSCHEST:
17680 69 temp_combo.attrishorts[2] = -1;
17681 69 temp_combo.usrflags |= cflag7;
17682 69 break;
17683 }
17684 873209 }
17685
2/2
✓ Branch 0 taken 68884 times.
✓ Branch 1 taken 804325 times.
873209 if(section_version < 20)
17686 {
17687 804325 temp_combo.genflags = 0;
17688
2/2
✓ Branch 0 taken 19291 times.
✓ Branch 1 taken 785034 times.
804325 switch(temp_combo.type)
17689 {
17690 case cPUSH_WAIT: case cPUSH_HEAVY:
17691 case cPUSH_HW: case cL_STATUE:
17692 case cR_STATUE: case cPUSH_HEAVY2:
17693 case cPUSH_HW2: case cPOUND:
17694 case cC_STATUE: case cMIRROR:
17695 case cMIRRORSLASH: case cMIRRORBACKSLASH:
17696 case cMAGICPRISM: case cMAGICPRISM4:
17697 case cMAGICSPONGE: case cEYEBALL_A:
17698 case cEYEBALL_B: case cEYEBALL_4:
17699 case cBUSH: case cFLOWERS:
17700 case cLOCKBLOCK: case cLOCKBLOCK2:
17701 case cBOSSLOCKBLOCK: case cBOSSLOCKBLOCK2:
17702 case cCHEST: case cCHEST2:
17703 case cLOCKEDCHEST: case cLOCKEDCHEST2:
17704 case cBOSSCHEST: case cBOSSCHEST2:
17705 case cBUSHNEXT: case cBUSHTOUCHY:
17706 case cFLOWERSTOUCHY: case cBUSHNEXTTOUCHY:
17707 case cSIGNPOST: case cCSWITCHBLOCK:
17708 case cTORCH: case cTRIGGERGENERIC:
17709
1/2
✓ Branch 0 taken 19291 times.
✗ Branch 1 not taken.
19291 if(temp_combo.usrflags & cflag16)
17710 {
17711 temp_combo.genflags |= cflag1;
17712 temp_combo.usrflags &= ~cflag16;
17713 }
17714 19291 break;
17715 }
17716 804325 }
17717
17718 873209 update_combo(temp_combo, section_version);
17719
17720
2/4
✓ Branch 0 taken 873209 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 873209 times.
✗ Branch 3 not taken.
873209 if(i>=start_combo && !should_skip)
17721 {
17722
1/2
✓ Branch 0 taken 873209 times.
✗ Branch 1 not taken.
873209 if(loading_tileset_flags & TILESET_CLEARSCRIPTS)
17723 {
17724 temp_combo.script = 0;
17725 for(int q = 0; q < 8; ++q)
17726 temp_combo.initd[q] = 0;
17727 }
17728
1/2
✓ Branch 0 taken 873209 times.
✗ Branch 1 not taken.
873209 combobuf[i] = temp_combo;
17729 873209 }
17730 873209 }
17731
17732
1/2
✓ Branch 0 taken 95 times.
✗ Branch 1 not taken.
95 if (should_skip)
17733 return 0;
17734
17735
3/6
✓ Branch 0 taken 91 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 91 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
95 if((version < 0x192)|| ((version == 0x192)&&(build<185)))
17736 {
17737
2/2
✓ Branch 0 taken 261120 times.
✓ Branch 1 taken 4 times.
261124 for(int32_t tmpcounter=0; tmpcounter<MAXCOMBOS; tmpcounter++)
17738 {
17739
1/2
✓ Branch 0 taken 261120 times.
✗ Branch 1 not taken.
261120 if(combobuf[tmpcounter].type==cHOOKSHOTONLY)
17740 {
17741 combobuf[tmpcounter].type=cLADDERHOOKSHOT;
17742 }
17743 261120 }
17744 4 }
17745
17746 //June 3 2012; ladder only is broken in 2.10 and allows the hookshot also. -Gleeok
17747
4/6
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 83 times.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 12 times.
95 if(version == 0x210 && !is_editor())
17748 {
17749
2/2
✓ Branch 0 taken 783360 times.
✓ Branch 1 taken 12 times.
783372 for(int32_t tmpcounter=0; tmpcounter<MAXCOMBOS; tmpcounter++)
17750
2/2
✓ Branch 0 taken 783351 times.
✓ Branch 1 taken 9 times.
783369 if(combobuf[tmpcounter].type == cLADDERONLY)
17751 9 combobuf[tmpcounter].type = cLADDERHOOKSHOT;
17752 12 }
17753
17754
2/2
✓ Branch 0 taken 79 times.
✓ Branch 1 taken 16 times.
95 if(section_version<7)
17755 {
17756
2/2
✓ Branch 0 taken 1044480 times.
✓ Branch 1 taken 16 times.
1044496 for(int32_t tmpcounter=0; tmpcounter<MAXCOMBOS; tmpcounter++)
17757 {
17758
6/9
✓ Branch 0 taken 1043840 times.
✓ Branch 1 taken 250 times.
✓ Branch 2 taken 174 times.
✓ Branch 3 taken 126 times.
✓ Branch 4 taken 45 times.
✓ Branch 5 taken 45 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
1044480 switch(combobuf[tmpcounter].type)
17759 {
17760 case cSLASH:
17761 250 combobuf[tmpcounter].type=cSLASHTOUCHY;
17762 250 break;
17763
17764 case cSLASHITEM:
17765 174 combobuf[tmpcounter].type=cSLASHITEMTOUCHY;
17766 174 break;
17767
17768 case cBUSH:
17769 126 combobuf[tmpcounter].type=cBUSHTOUCHY;
17770 126 break;
17771
17772 case cFLOWERS:
17773 45 combobuf[tmpcounter].type=cFLOWERSTOUCHY;
17774 45 break;
17775
17776 case cTALLGRASS:
17777 45 combobuf[tmpcounter].type=cTALLGRASSTOUCHY;
17778 45 break;
17779
17780 case cSLASHNEXT:
17781 combobuf[tmpcounter].type=cSLASHNEXTTOUCHY;
17782 break;
17783
17784 case cSLASHNEXTITEM:
17785 combobuf[tmpcounter].type=cSLASHNEXTITEMTOUCHY;
17786 break;
17787
17788 case cBUSHNEXT:
17789 combobuf[tmpcounter].type=cBUSHNEXTTOUCHY;
17790 break;
17791 }
17792 1044480 }
17793 16 }
17794
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 93 times.
95 if (section_version < 16)
17795 {
17796
2/2
✓ Branch 0 taken 6071040 times.
✓ Branch 1 taken 93 times.
6071133 for(int32_t tmpcounter=0; tmpcounter<MAXCOMBOS; tmpcounter++)
17797 {
17798
2/2
✓ Branch 0 taken 6062986 times.
✓ Branch 1 taken 8054 times.
6071040 if (combobuf[tmpcounter].type == cWATER)
17799 {
17800 8054 combobuf[tmpcounter].attributes[0] = 40000L;
17801 8054 }
17802 6071040 }
17803 93 }
17804
3/4
✓ Branch 0 taken 95 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 94 times.
✓ Branch 3 taken 1 times.
95 if(!get_qr(qr_ALLOW_EDITING_COMBO_0))
17805 {
17806 1 combobuf[0].walk = 0xF0;
17807 1 combobuf[0].type = 0;
17808 1 combobuf[0].flag = 0;
17809 1 }
17810
17811 //Now for the new combo alias reset
17812
2/2
✓ Branch 0 taken 79 times.
✓ Branch 1 taken 16 times.
95 if(section_version<2)
17813 {
17814
2/2
✓ Branch 0 taken 131072 times.
✓ Branch 1 taken 16 times.
131088 for(int32_t j=0; j<MAXCOMBOALIASES; j++)
17815 {
17816 131072 combo_aliases[j].width = 0;
17817 131072 combo_aliases[j].height = 0;
17818 131072 combo_aliases[j].layermask = 0;
17819
17820
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 131072 times.
131072 if(combo_aliases[j].combos != NULL)
17821 {
17822
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 131072 times.
131072 delete[] combo_aliases[j].combos;
17823 131072 }
17824
17825
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 131072 times.
131072 if(combo_aliases[j].csets != NULL)
17826 {
17827
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 131072 times.
131072 delete[] combo_aliases[j].csets;
17828 131072 }
17829
17830
1/2
✓ Branch 0 taken 131072 times.
✗ Branch 1 not taken.
131072 combo_aliases[j].combos = new word[1];
17831
1/2
✓ Branch 0 taken 131072 times.
✗ Branch 1 not taken.
131072 combo_aliases[j].csets = new byte[1];
17832 131072 combo_aliases[j].combos[0] = 0;
17833 131072 combo_aliases[j].csets[0] = 0;
17834 131072 }
17835 16 }
17836
17837
17838
1/2
✓ Branch 0 taken 95 times.
✗ Branch 1 not taken.
95 setup_combo_animations();
17839
1/2
✓ Branch 0 taken 95 times.
✗ Branch 1 not taken.
95 setup_combo_animations2();
17840 95 return 0;
17841 95 }
17842 216104 int32_t readcombo_loop(PACKFILE* f, word s_version, newcombo& temp_combo)
17843 {
17844 byte combo_has_flags;
17845
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 216104 times.
216104 if(!p_getc(&combo_has_flags,f))
17846 return qe_invalid;
17847
17848 216104 temp_combo.clear();
17849
2/2
✓ Branch 0 taken 143823 times.
✓ Branch 1 taken 72281 times.
216104 if(combo_has_flags)
17850 {
17851
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 72278 times.
72281 if(combo_has_flags&CHAS_BASIC)
17852 {
17853
1/2
✓ Branch 0 taken 72278 times.
✗ Branch 1 not taken.
72278 if(!p_igetl(&temp_combo.tile,f))
17854 {
17855 return qe_invalid;
17856 }
17857 72278 temp_combo.o_tile = temp_combo.tile;
17858
17859
1/2
✓ Branch 0 taken 72278 times.
✗ Branch 1 not taken.
72278 if(!p_getc(&temp_combo.flip,f))
17860 {
17861 return qe_invalid;
17862 }
17863
17864
1/2
✓ Branch 0 taken 72278 times.
✗ Branch 1 not taken.
72278 if(!p_getc(&temp_combo.walk,f))
17865 {
17866 return qe_invalid;
17867 }
17868
17869
1/2
✓ Branch 0 taken 72278 times.
✗ Branch 1 not taken.
72278 if(!p_getc(&temp_combo.type,f))
17870 {
17871 return qe_invalid;
17872 }
17873
17874
1/2
✓ Branch 0 taken 72278 times.
✗ Branch 1 not taken.
72278 if(!p_getc(&temp_combo.flag,f))
17875 {
17876 return qe_invalid;
17877 }
17878
17879
1/2
✓ Branch 0 taken 72278 times.
✗ Branch 1 not taken.
72278 if(!p_getc(&temp_combo.csets,f))
17880 {
17881 return qe_invalid;
17882 }
17883 72278 }
17884
2/2
✓ Branch 0 taken 72258 times.
✓ Branch 1 taken 23 times.
72281 if(combo_has_flags&CHAS_SCRIPT)
17885 {
17886
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 15 times.
23 if (s_version>=41)
17887 {
17888 8 p_getcstr(&temp_combo.label, f);
17889 8 }
17890 else
17891 {
17892 char label[12];
17893 15 label[11] = '\0';
17894
2/2
✓ Branch 0 taken 165 times.
✓ Branch 1 taken 15 times.
180 for ( int32_t q = 0; q < 11; q++ )
17895 {
17896
1/2
✓ Branch 0 taken 165 times.
✗ Branch 1 not taken.
165 if(!p_getc(&label[q],f))
17897 {
17898 return qe_invalid;
17899 }
17900 165 }
17901 15 temp_combo.label = label;
17902 }
17903
17904
1/2
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
23 if(!p_igetw(&temp_combo.script,f)) return qe_invalid;
17905 23 auto initd_count = s_version >= 43 ? 8 : 2;
17906
2/2
✓ Branch 0 taken 94 times.
✓ Branch 1 taken 23 times.
117 for ( int32_t q = 0; q < initd_count; q++ )
17907 {
17908
1/2
✓ Branch 0 taken 94 times.
✗ Branch 1 not taken.
94 if(!p_igetl(&temp_combo.initd[q],f))
17909 {
17910 return qe_invalid;
17911 }
17912 94 }
17913 23 }
17914
2/2
✓ Branch 0 taken 52274 times.
✓ Branch 1 taken 20007 times.
72281 if(combo_has_flags&CHAS_ANIM)
17915 {
17916
1/2
✓ Branch 0 taken 20007 times.
✗ Branch 1 not taken.
20007 if(!p_getc(&temp_combo.frames,f))
17917 {
17918 return qe_invalid;
17919 }
17920
17921
1/2
✓ Branch 0 taken 20007 times.
✗ Branch 1 not taken.
20007 if(!p_getc(&temp_combo.speed,f))
17922 {
17923 return qe_invalid;
17924 }
17925
17926
1/2
✓ Branch 0 taken 20007 times.
✗ Branch 1 not taken.
20007 if(!p_igetw(&temp_combo.nextcombo,f))
17927 {
17928 return qe_invalid;
17929 }
17930
17931
1/2
✓ Branch 0 taken 20007 times.
✗ Branch 1 not taken.
20007 if(!p_getc(&temp_combo.nextcset,f))
17932 {
17933 return qe_invalid;
17934 }
17935
17936
1/2
✓ Branch 0 taken 20007 times.
✗ Branch 1 not taken.
20007 if(!p_getc(&temp_combo.skipanim,f))
17937 {
17938 return qe_invalid;
17939 }
17940
17941
1/2
✓ Branch 0 taken 20007 times.
✗ Branch 1 not taken.
20007 if(!p_getc(&temp_combo.skipanimy,f))
17942 {
17943 return qe_invalid;
17944 }
17945
17946
1/2
✓ Branch 0 taken 20007 times.
✗ Branch 1 not taken.
20007 if(!p_getc(&temp_combo.animflags,f))
17947 {
17948 return qe_invalid;
17949 }
17950 20007 }
17951
2/2
✓ Branch 0 taken 63735 times.
✓ Branch 1 taken 8546 times.
72281 if(combo_has_flags&CHAS_ATTRIB)
17952 {
17953
2/2
✓ Branch 0 taken 34184 times.
✓ Branch 1 taken 8546 times.
42730 for ( int32_t q = 0; q < 4; q++ )
17954 {
17955
1/2
✓ Branch 0 taken 34184 times.
✗ Branch 1 not taken.
34184 if(!p_igetl(&temp_combo.attributes[q],f))
17956 {
17957 return qe_invalid;
17958 }
17959 34184 }
17960
2/2
✓ Branch 0 taken 68368 times.
✓ Branch 1 taken 8546 times.
76914 for ( int32_t q = 0; q < 8; q++ )
17961 {
17962
1/2
✓ Branch 0 taken 68368 times.
✗ Branch 1 not taken.
68368 if(!p_getc(&temp_combo.attribytes[q],f))
17963 {
17964 return qe_invalid;
17965 }
17966 68368 }
17967
2/2
✓ Branch 0 taken 68368 times.
✓ Branch 1 taken 8546 times.
76914 for ( int32_t q = 0; q < 8; q++ )
17968 {
17969
1/2
✓ Branch 0 taken 68368 times.
✗ Branch 1 not taken.
68368 if(!p_igetw(&temp_combo.attrishorts[q],f))
17970 {
17971 return qe_invalid;
17972 }
17973 68368 }
17974 8546 }
17975
2/2
✓ Branch 0 taken 70161 times.
✓ Branch 1 taken 2120 times.
72281 if(combo_has_flags&CHAS_FLAG)
17976 {
17977
1/2
✓ Branch 0 taken 2120 times.
✗ Branch 1 not taken.
2120 if(!p_igetl(&temp_combo.usrflags,f))
17978 {
17979 return qe_invalid;
17980 }
17981
1/2
✓ Branch 0 taken 2120 times.
✗ Branch 1 not taken.
2120 if(!p_igetw(&temp_combo.genflags,f))
17982 {
17983 return qe_invalid;
17984 }
17985 2120 }
17986
2/2
✓ Branch 0 taken 71527 times.
✓ Branch 1 taken 754 times.
72281 if(combo_has_flags&CHAS_TRIG)
17987 {
17988 754 int numtrigs = s_version < 36 ? 3 : 6;
17989
2/2
✓ Branch 0 taken 4095 times.
✓ Branch 1 taken 754 times.
4849 for ( int32_t q = 0; q < numtrigs; q++ )
17990 {
17991
1/2
✓ Branch 0 taken 4095 times.
✗ Branch 1 not taken.
4095 if(!p_igetl(&temp_combo.triggerflags[q],f))
17992 {
17993 return qe_invalid;
17994 }
17995 4095 }
17996
1/2
✓ Branch 0 taken 754 times.
✗ Branch 1 not taken.
754 if(!p_igetl(&temp_combo.triggerlevel,f))
17997 {
17998 return qe_invalid;
17999 }
18000
1/2
✓ Branch 0 taken 754 times.
✗ Branch 1 not taken.
754 if(!p_getc(&temp_combo.triggerbtn,f))
18001 {
18002 return qe_invalid;
18003 }
18004
1/2
✓ Branch 0 taken 754 times.
✗ Branch 1 not taken.
754 if(!p_getc(&temp_combo.triggeritem,f))
18005 {
18006 return qe_invalid;
18007 }
18008
1/2
✓ Branch 0 taken 754 times.
✗ Branch 1 not taken.
754 if(!p_getc(&temp_combo.trigtimer,f))
18009 {
18010 return qe_invalid;
18011 }
18012
1/2
✓ Branch 0 taken 754 times.
✗ Branch 1 not taken.
754 if(!p_getc(&temp_combo.trigsfx,f))
18013 {
18014 return qe_invalid;
18015 }
18016
1/2
✓ Branch 0 taken 754 times.
✗ Branch 1 not taken.
754 if(!p_igetl(&temp_combo.trigchange,f))
18017 {
18018 return qe_invalid;
18019 }
18020
1/2
✓ Branch 0 taken 754 times.
✗ Branch 1 not taken.
754 if(!p_igetw(&temp_combo.trigprox,f))
18021 {
18022 return qe_invalid;
18023 }
18024
1/2
✓ Branch 0 taken 754 times.
✗ Branch 1 not taken.
754 if(!p_getc(&temp_combo.trigctr,f))
18025 {
18026 return qe_invalid;
18027 }
18028
1/2
✓ Branch 0 taken 754 times.
✗ Branch 1 not taken.
754 if(!p_igetl(&temp_combo.trigctramnt,f))
18029 {
18030 return qe_invalid;
18031 }
18032
1/2
✓ Branch 0 taken 754 times.
✗ Branch 1 not taken.
754 if(!p_getc(&temp_combo.triglbeam,f))
18033 {
18034 return qe_invalid;
18035 }
18036
1/2
✓ Branch 0 taken 754 times.
✗ Branch 1 not taken.
754 if(!p_getc(&temp_combo.trigcschange,f))
18037 {
18038 return qe_invalid;
18039 }
18040
1/2
✓ Branch 0 taken 754 times.
✗ Branch 1 not taken.
754 if(!p_igetw(&temp_combo.spawnitem,f))
18041 {
18042 return qe_invalid;
18043 }
18044
1/2
✓ Branch 0 taken 754 times.
✗ Branch 1 not taken.
754 if(!p_igetw(&temp_combo.spawnenemy,f))
18045 {
18046 return qe_invalid;
18047 }
18048
1/2
✓ Branch 0 taken 754 times.
✗ Branch 1 not taken.
754 if(!p_getc(&temp_combo.exstate,f))
18049 {
18050 return qe_invalid;
18051 }
18052
1/2
✓ Branch 0 taken 754 times.
✗ Branch 1 not taken.
754 if(!p_igetl(&temp_combo.spawnip,f))
18053 {
18054 return qe_invalid;
18055 }
18056
1/2
✓ Branch 0 taken 754 times.
✗ Branch 1 not taken.
754 if(!p_getc(&temp_combo.trigcopycat,f))
18057 {
18058 return qe_invalid;
18059 }
18060
1/2
✓ Branch 0 taken 754 times.
✗ Branch 1 not taken.
754 if(!p_getc(&temp_combo.trigcooldown,f))
18061 {
18062 return qe_invalid;
18063 }
18064
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 754 times.
754 if(s_version >= 35)
18065 {
18066
1/2
✓ Branch 0 taken 754 times.
✗ Branch 1 not taken.
754 if(!p_igetw(&temp_combo.prompt_cid,f))
18067 {
18068 return qe_invalid;
18069 }
18070
1/2
✓ Branch 0 taken 754 times.
✗ Branch 1 not taken.
754 if(!p_getc(&temp_combo.prompt_cs,f))
18071 {
18072 return qe_invalid;
18073 }
18074
1/2
✓ Branch 0 taken 754 times.
✗ Branch 1 not taken.
754 if(!p_igetw(&temp_combo.prompt_x,f))
18075 {
18076 return qe_invalid;
18077 }
18078
1/2
✓ Branch 0 taken 754 times.
✗ Branch 1 not taken.
754 if(!p_igetw(&temp_combo.prompt_y,f))
18079 {
18080 return qe_invalid;
18081 }
18082 754 }
18083
2/2
✓ Branch 0 taken 143 times.
✓ Branch 1 taken 611 times.
754 if(s_version >= 36)
18084 {
18085
1/2
✓ Branch 0 taken 611 times.
✗ Branch 1 not taken.
611 if(!p_getc(&temp_combo.trig_lstate,f))
18086 {
18087 return qe_invalid;
18088 }
18089
1/2
✓ Branch 0 taken 611 times.
✗ Branch 1 not taken.
611 if(!p_getc(&temp_combo.trig_gstate,f))
18090 {
18091 return qe_invalid;
18092 }
18093
1/2
✓ Branch 0 taken 611 times.
✗ Branch 1 not taken.
611 if(!p_igetl(&temp_combo.trig_statetime,f))
18094 {
18095 return qe_invalid;
18096 }
18097 611 }
18098
2/2
✓ Branch 0 taken 143 times.
✓ Branch 1 taken 611 times.
754 if(s_version >= 37)
18099 {
18100
1/2
✓ Branch 0 taken 611 times.
✗ Branch 1 not taken.
611 if(!p_igetw(&temp_combo.trig_genscr,f))
18101 {
18102 return qe_invalid;
18103 }
18104 611 }
18105
2/2
✓ Branch 0 taken 217 times.
✓ Branch 1 taken 537 times.
754 if(s_version >= 38)
18106 {
18107
1/2
✓ Branch 0 taken 537 times.
✗ Branch 1 not taken.
537 if(!p_getc(&temp_combo.trig_group,f))
18108 {
18109 return qe_invalid;
18110 }
18111
1/2
✓ Branch 0 taken 537 times.
✗ Branch 1 not taken.
537 if(!p_igetw(&temp_combo.trig_group_val,f))
18112 {
18113 return qe_invalid;
18114 }
18115 537 }
18116 754 }
18117
2/2
✓ Branch 0 taken 72142 times.
✓ Branch 1 taken 139 times.
72281 if(combo_has_flags&CHAS_LIFT)
18118 {
18119
1/2
✓ Branch 0 taken 139 times.
✗ Branch 1 not taken.
139 if(!p_igetw(&temp_combo.liftcmb,f))
18120 return qe_invalid;
18121
1/2
✓ Branch 0 taken 139 times.
✗ Branch 1 not taken.
139 if(!p_getc(&temp_combo.liftcs,f))
18122 return qe_invalid;
18123
1/2
✓ Branch 0 taken 139 times.
✗ Branch 1 not taken.
139 if(!p_igetw(&temp_combo.liftundercmb,f))
18124 return qe_invalid;
18125
1/2
✓ Branch 0 taken 139 times.
✗ Branch 1 not taken.
139 if(!p_getc(&temp_combo.liftundercs,f))
18126 return qe_invalid;
18127
1/2
✓ Branch 0 taken 139 times.
✗ Branch 1 not taken.
139 if(!p_getc(&temp_combo.liftdmg,f))
18128 return qe_invalid;
18129
1/2
✓ Branch 0 taken 139 times.
✗ Branch 1 not taken.
139 if(!p_getc(&temp_combo.liftlvl,f))
18130 return qe_invalid;
18131
1/2
✓ Branch 0 taken 139 times.
✗ Branch 1 not taken.
139 if(!p_getc(&temp_combo.liftitm,f))
18132 return qe_invalid;
18133
1/2
✓ Branch 0 taken 139 times.
✗ Branch 1 not taken.
139 if(!p_getc(&temp_combo.liftflags,f))
18134 return qe_invalid;
18135
1/2
✓ Branch 0 taken 139 times.
✗ Branch 1 not taken.
139 if(!p_getc(&temp_combo.liftgfx,f))
18136 return qe_invalid;
18137
1/2
✓ Branch 0 taken 139 times.
✗ Branch 1 not taken.
139 if(!p_getc(&temp_combo.liftsprite,f))
18138 return qe_invalid;
18139
1/2
✓ Branch 0 taken 139 times.
✗ Branch 1 not taken.
139 if(!p_getc(&temp_combo.liftsfx,f))
18140 return qe_invalid;
18141
1/2
✓ Branch 0 taken 139 times.
✗ Branch 1 not taken.
139 if(!p_igetw(&temp_combo.liftbreaksprite,f))
18142 return qe_invalid;
18143
1/2
✓ Branch 0 taken 139 times.
✗ Branch 1 not taken.
139 if(!p_getc(&temp_combo.liftbreaksfx,f))
18144 return qe_invalid;
18145
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 139 times.
139 if(s_version >= 34)
18146 {
18147
1/2
✓ Branch 0 taken 139 times.
✗ Branch 1 not taken.
139 if(!p_getc(&temp_combo.lifthei,f))
18148 return qe_invalid;
18149
1/2
✓ Branch 0 taken 139 times.
✗ Branch 1 not taken.
139 if(!p_getc(&temp_combo.lifttime,f))
18150 return qe_invalid;
18151 139 }
18152
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 132 times.
139 if(s_version >= 39)
18153 {
18154
1/2
✓ Branch 0 taken 132 times.
✗ Branch 1 not taken.
132 if(!p_getc(&temp_combo.lift_parent_item,f))
18155 return qe_invalid;
18156 132 }
18157 139 }
18158
2/2
✓ Branch 0 taken 72193 times.
✓ Branch 1 taken 88 times.
72281 if(combo_has_flags&CHAS_GENERAL)
18159 {
18160
1/2
✓ Branch 0 taken 88 times.
✗ Branch 1 not taken.
88 if(!p_getc(&temp_combo.speed_mult,f))
18161 return qe_invalid;
18162
1/2
✓ Branch 0 taken 88 times.
✗ Branch 1 not taken.
88 if(!p_getc(&temp_combo.speed_div,f))
18163 return qe_invalid;
18164
1/2
✓ Branch 0 taken 88 times.
✗ Branch 1 not taken.
88 if(!p_igetzf(&temp_combo.speed_add,f))
18165 return qe_invalid;
18166
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 88 times.
88 if(s_version >= 42)
18167 {
18168
1/2
✓ Branch 0 taken 88 times.
✗ Branch 1 not taken.
88 if(!p_getc(&temp_combo.sfx_appear,f))
18169 return qe_invalid;
18170
1/2
✓ Branch 0 taken 88 times.
✗ Branch 1 not taken.
88 if(!p_getc(&temp_combo.sfx_disappear,f))
18171 return qe_invalid;
18172
1/2
✓ Branch 0 taken 88 times.
✗ Branch 1 not taken.
88 if(!p_getc(&temp_combo.sfx_loop,f))
18173 return qe_invalid;
18174
1/2
✓ Branch 0 taken 88 times.
✗ Branch 1 not taken.
88 if(!p_getc(&temp_combo.sfx_walking,f))
18175 return qe_invalid;
18176
1/2
✓ Branch 0 taken 88 times.
✗ Branch 1 not taken.
88 if(!p_getc(&temp_combo.sfx_standing,f))
18177 return qe_invalid;
18178
1/2
✓ Branch 0 taken 88 times.
✗ Branch 1 not taken.
88 if(!p_getc(&temp_combo.spr_appear,f))
18179 return qe_invalid;
18180
1/2
✓ Branch 0 taken 88 times.
✗ Branch 1 not taken.
88 if(!p_getc(&temp_combo.spr_disappear,f))
18181 return qe_invalid;
18182
1/2
✓ Branch 0 taken 88 times.
✗ Branch 1 not taken.
88 if(!p_getc(&temp_combo.spr_walking,f))
18183 return qe_invalid;
18184
1/2
✓ Branch 0 taken 88 times.
✗ Branch 1 not taken.
88 if(!p_getc(&temp_combo.spr_standing,f))
18185 return qe_invalid;
18186 88 }
18187 88 }
18188 72281 }
18189 216104 update_combo(temp_combo, s_version);
18190 216104 return 0;
18191 216104 }
18192 128 int32_t readcombos(PACKFILE *f, zquestheader *Header, word version, word build, word start_combo, word max_combos)
18193 {
18194
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 124 times.
128 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_combos);
18195
18196 128 word section_version=0;
18197 128 word section_cversion=0;
18198 128 word combos_used=0;
18199 int32_t dummy;
18200 byte padding;
18201 128 newcombo temp_combo;
18202
18203
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 128 times.
128 if (!should_skip)
18204 {
18205
1/2
✓ Branch 0 taken 128 times.
✗ Branch 1 not taken.
128 reset_combo_animations();
18206
1/2
✓ Branch 0 taken 128 times.
✗ Branch 1 not taken.
128 reset_combo_animations2();
18207
1/2
✓ Branch 0 taken 128 times.
✗ Branch 1 not taken.
128 init_combo_classes();
18208
18209
2/2
✓ Branch 0 taken 8355840 times.
✓ Branch 1 taken 128 times.
8355968 for(int32_t q = start_combo; q < start_combo+max_combos; ++q)
18210
1/2
✓ Branch 0 taken 8355840 times.
✗ Branch 1 not taken.
8355840 combobuf[q].clear();
18211 128 }
18212
18213
2/2
✓ Branch 0 taken 124 times.
✓ Branch 1 taken 4 times.
128 if(version > 0x192) //Version info
18214 {
18215
2/4
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 124 times.
✗ Branch 3 not taken.
124 if(!p_igetw(&section_version,f))
18216 {
18217 return qe_invalid;
18218 }
18219 124 FFCore.quest_format[vCombos] = section_version;
18220
2/4
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 124 times.
✗ Branch 3 not taken.
124 if(!p_igetw(&section_cversion,f))
18221 {
18222 return qe_invalid;
18223 }
18224
18225 //section size
18226
2/4
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 124 times.
✗ Branch 3 not taken.
124 if(!p_igetl(&dummy,f))
18227 {
18228 return qe_invalid;
18229 }
18230 124 }
18231
18232
2/2
✓ Branch 0 taken 33 times.
✓ Branch 1 taken 95 times.
128 if(section_version > 32) //Cleanup time!
18233 {
18234
2/4
✓ Branch 0 taken 33 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 33 times.
✗ Branch 3 not taken.
33 if(!p_igetw(&combos_used,f))
18235 {
18236 return qe_invalid;
18237 }
18238
2/2
✓ Branch 0 taken 216104 times.
✓ Branch 1 taken 33 times.
216137 for(int32_t i=0; i<combos_used; i++)
18239 {
18240
1/2
✓ Branch 0 taken 216104 times.
✗ Branch 1 not taken.
216104 auto ret = readcombo_loop(f,section_version,temp_combo);
18241
1/2
✓ Branch 0 taken 216104 times.
✗ Branch 1 not taken.
216104 if(ret) return ret;
18242
1/2
✓ Branch 0 taken 216104 times.
✗ Branch 1 not taken.
216104 if(i>=start_combo)
18243 {
18244
1/2
✓ Branch 0 taken 216104 times.
✗ Branch 1 not taken.
216104 if(loading_tileset_flags & TILESET_CLEARSCRIPTS)
18245 {
18246 temp_combo.script = 0;
18247 for(int q = 0; q < 8; ++q)
18248 temp_combo.initd[q] = 0;
18249 }
18250
1/2
✓ Branch 0 taken 216104 times.
✗ Branch 1 not taken.
216104 combobuf[i] = temp_combo;
18251 216104 }
18252 216104 }
18253 33 }
18254 else //Call the old function for all old versions
18255 {
18256
1/2
✓ Branch 0 taken 95 times.
✗ Branch 1 not taken.
95 auto ret = readcombos_old(section_version,f,Header,version,build,start_combo,max_combos);
18257
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 95 times.
95 if(ret) return ret; //error, end read
18258 }
18259
18260
1/2
✓ Branch 0 taken 128 times.
✗ Branch 1 not taken.
128 if (should_skip)
18261 return 0;
18262
18263
3/4
✓ Branch 0 taken 128 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 96 times.
✓ Branch 3 taken 32 times.
128 if(!get_qr(qr_ALLOW_EDITING_COMBO_0))
18264 {
18265 32 combobuf[0].walk = 0xF0;
18266 32 combobuf[0].type = 0;
18267 32 combobuf[0].flag = 0;
18268 32 }
18269
18270
1/2
✓ Branch 0 taken 128 times.
✗ Branch 1 not taken.
128 setup_combo_animations();
18271
1/2
✓ Branch 0 taken 128 times.
✗ Branch 1 not taken.
128 setup_combo_animations2();
18272 128 return 0;
18273 128 }
18274
18275 112 int32_t readcomboaliases(PACKFILE *f, zquestheader *Header, word version, word build)
18276 {
18277 //these are here to bypass compiler warnings about unused arguments
18278 112 Header=Header;
18279 112 version=version;
18280 112 build=build;
18281
18282 int32_t dummy;
18283 112 word sversion=0, c_sversion;
18284
18285 //section version info
18286
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 112 times.
112 if(!p_igetw(&sversion,f))
18287 {
18288 return qe_invalid;
18289 }
18290
18291 112 FFCore.quest_format[vComboAliases] = sversion;
18292
18293 //al_trace("Combo aliases version %d\n", sversion);
18294
1/2
✓ Branch 0 taken 112 times.
✗ Branch 1 not taken.
112 if(!p_igetw(&c_sversion,f))
18295 {
18296 return qe_invalid;
18297 }
18298
18299 //section size
18300
1/2
✓ Branch 0 taken 112 times.
✗ Branch 1 not taken.
112 if(!p_igetl(&dummy,f))
18301 {
18302 return qe_invalid;
18303 }
18304
18305 112 int32_t max_num_combo_aliases = MAXCOMBOALIASES;
18306
18307
2/2
✓ Branch 0 taken 35 times.
✓ Branch 1 taken 77 times.
112 if(sversion < 3) // max saved combo alias' upped from 256 to 2048.
18308 {
18309 77 max_num_combo_aliases = MAX250COMBOALIASES;
18310 77 }
18311
1/2
✓ Branch 0 taken 112 times.
✗ Branch 1 not taken.
112 if(sversion < 2) // max saved combo alias' upped from 256 to 2048.
18312 {
18313 max_num_combo_aliases = OLDMAXCOMBOALIASES;
18314 }
18315
18316
2/2
✓ Branch 0 taken 444416 times.
✓ Branch 1 taken 112 times.
444528 for(int32_t j=0; j<max_num_combo_aliases; j++)
18317 {
18318 byte width,height,mask,tempcset;
18319 int32_t count;
18320 word tempword;
18321 byte tempbyte;
18322
18323
1/2
✓ Branch 0 taken 444416 times.
✗ Branch 1 not taken.
444416 if(!p_igetw(&tempword,f))
18324 {
18325 return qe_invalid;
18326 }
18327
18328 444416 combo_aliases[j].combo = tempword;
18329
18330
1/2
✓ Branch 0 taken 444416 times.
✗ Branch 1 not taken.
444416 if(!p_getc(&tempbyte,f))
18331 {
18332 return qe_invalid;
18333 }
18334
18335 444416 combo_aliases[j].cset = tempbyte;
18336
18337
1/2
✓ Branch 0 taken 444416 times.
✗ Branch 1 not taken.
444416 if(!p_getc(&width,f))
18338 {
18339 return qe_invalid;
18340 }
18341
18342
1/2
✓ Branch 0 taken 444416 times.
✗ Branch 1 not taken.
444416 if(!p_getc(&height,f))
18343 {
18344 return qe_invalid;
18345 }
18346
18347
1/2
✓ Branch 0 taken 444416 times.
✗ Branch 1 not taken.
444416 if(!p_getc(&mask,f))
18348 {
18349 return qe_invalid;
18350 }
18351
18352 444416 count=(width+1)*(height+1)*(comboa_lmasktotal(mask)+1);
18353
18354
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 444416 times.
444416 if(combo_aliases[j].combos != NULL)
18355 {
18356
1/2
✓ Branch 0 taken 444416 times.
✗ Branch 1 not taken.
444416 delete[] combo_aliases[j].combos;
18357 444416 }
18358
18359
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 444416 times.
444416 if(combo_aliases[j].csets != NULL)
18360 {
18361
1/2
✓ Branch 0 taken 444416 times.
✗ Branch 1 not taken.
444416 delete[] combo_aliases[j].csets;
18362 444416 }
18363
18364 444416 combo_aliases[j].width = width;
18365 444416 combo_aliases[j].height = height;
18366 444416 combo_aliases[j].layermask = mask;
18367 444416 combo_aliases[j].combos = new word[count];
18368 444416 combo_aliases[j].csets = new byte[count];
18369
18370
2/2
✓ Branch 0 taken 455381 times.
✓ Branch 1 taken 444416 times.
899797 for(int32_t k=0; k<count; k++)
18371 {
18372
1/2
✓ Branch 0 taken 455381 times.
✗ Branch 1 not taken.
455381 if(!p_igetw(&tempword,f))
18373 {
18374 return qe_invalid;
18375 }
18376
18377 455381 combo_aliases[j].combos[k] = tempword;
18378 455381 }
18379
18380
2/2
✓ Branch 0 taken 455381 times.
✓ Branch 1 taken 444416 times.
899797 for(int32_t k=0; k<count; k++)
18381 {
18382
1/2
✓ Branch 0 taken 455381 times.
✗ Branch 1 not taken.
455381 if(!p_getc(&tempcset,f))
18383 {
18384 return qe_invalid;
18385 }
18386
18387 455381 combo_aliases[j].csets[k] = tempcset;
18388 455381 }
18389 444416 }
18390
18391 //Combo pools!
18392 112 word num_combo_pools = 0;
18393
2/2
✓ Branch 0 taken 79 times.
✓ Branch 1 taken 33 times.
112 if(sversion >= 4)
18394 {
18395
1/2
✓ Branch 0 taken 33 times.
✗ Branch 1 not taken.
33 if(!p_igetw(&num_combo_pools,f))
18396 {
18397 return qe_invalid;
18398 }
18399 33 }
18400
18401
2/2
✓ Branch 0 taken 917504 times.
✓ Branch 1 taken 112 times.
917616 for(combo_pool& pool : combo_pools)
18402 {
18403 917504 pool.clear();
18404 }
18405
18406 112 combo_pool temp_cpool;
18407
2/2
✓ Branch 0 taken 90 times.
✓ Branch 1 taken 112 times.
202 for(word cp = 0; cp < num_combo_pools; ++cp)
18408 {
18409 90 int32_t num_combos_in_pool = 0;
18410
2/4
✓ Branch 0 taken 90 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 90 times.
✗ Branch 3 not taken.
90 if(!p_igetl(&num_combos_in_pool,f))
18411 {
18412 return qe_invalid;
18413 }
18414
1/2
✓ Branch 0 taken 90 times.
✗ Branch 1 not taken.
90 if(num_combos_in_pool < 1) continue; //nothing to read
18415
18416
1/2
✓ Branch 0 taken 90 times.
✗ Branch 1 not taken.
90 temp_cpool.clear();
18417
18418 int32_t cp_cid; int8_t cp_cs; word cp_quant;
18419
2/2
✓ Branch 0 taken 90 times.
✓ Branch 1 taken 390 times.
480 for(auto q = 0; q < num_combos_in_pool; ++q)
18420 {
18421
2/4
✓ Branch 0 taken 390 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 390 times.
✗ Branch 3 not taken.
390 if(!p_igetl(&cp_cid,f))
18422 {
18423 return qe_invalid;
18424 }
18425
2/4
✓ Branch 0 taken 390 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 390 times.
✗ Branch 3 not taken.
390 if(!p_getc(&cp_cs,f))
18426 {
18427 return qe_invalid;
18428 }
18429
2/4
✓ Branch 0 taken 390 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 390 times.
✗ Branch 3 not taken.
390 if(!p_igetw(&cp_quant,f))
18430 {
18431 return qe_invalid;
18432 }
18433
1/2
✓ Branch 0 taken 390 times.
✗ Branch 1 not taken.
390 temp_cpool.add(cp_cid, cp_cs, cp_quant);
18434 390 }
18435
18436
1/2
✓ Branch 0 taken 90 times.
✗ Branch 1 not taken.
90 combo_pools[cp] = temp_cpool;
18437 90 }
18438
18439 //Autocombos!
18440 112 word num_combo_autos = 0;
18441
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 104 times.
112 if (sversion >= 5)
18442 {
18443
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 if (!p_igetw(&num_combo_autos, f))
18444 {
18445 return qe_invalid;
18446 }
18447 8 }
18448
18449
2/2
✓ Branch 0 taken 112 times.
✓ Branch 1 taken 917504 times.
917616 for (combo_auto& cauto : combo_autos)
18450 {
18451
1/2
✓ Branch 0 taken 917504 times.
✗ Branch 1 not taken.
917504 cauto.clear(true);
18452 }
18453
18454
1/2
✓ Branch 0 taken 112 times.
✗ Branch 1 not taken.
112 combo_auto temp_cauto;
18455
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 112 times.
136 for (word ca = 0; ca < num_combo_autos; ++ca)
18456 {
18457 byte type;
18458 int32_t display_cid, erase_cid;
18459 byte flags, arg;
18460
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
24 if (!p_getc(&type, f))
18461 {
18462 return qe_invalid;
18463 }
18464
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
24 if (!p_igetl(&display_cid, f))
18465 {
18466 return qe_invalid;
18467 }
18468
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
24 if (!p_igetl(&erase_cid, f))
18469 {
18470 return qe_invalid;
18471 }
18472
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
24 if (!p_getc(&flags, f))
18473 {
18474 return qe_invalid;
18475 }
18476
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
24 if (!p_getc(&arg, f))
18477 {
18478 return qe_invalid;
18479 }
18480 24 int32_t num_combos_in_cauto = 0;
18481
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
24 if (!p_igetl(&num_combos_in_cauto, f))
18482 {
18483 return qe_invalid;
18484 }
18485
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 if (num_combos_in_cauto < 1) continue; //nothing to read
18486
18487
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 temp_cauto.clear();
18488
18489
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 temp_cauto.setType(type);
18490
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 temp_cauto.setDisplay(display_cid);
18491
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 temp_cauto.setEraseCombo(erase_cid);
18492
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 temp_cauto.setFlags(flags);
18493
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 temp_cauto.setArg(arg);
18494
18495 int32_t ca_cid; byte ca_ctype; int16_t ca_offset; int16_t ca_engrave_offset;
18496
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 304 times.
328 for (auto q = 0; q < num_combos_in_cauto; ++q)
18497 {
18498
2/4
✓ Branch 0 taken 304 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 304 times.
✗ Branch 3 not taken.
304 if (!p_getc(&ca_ctype, f))
18499 {
18500 return qe_invalid;
18501 }
18502
2/4
✓ Branch 0 taken 304 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 304 times.
✗ Branch 3 not taken.
304 if (!p_igetl(&ca_cid, f))
18503 {
18504 return qe_invalid;
18505 }
18506
1/2
✓ Branch 0 taken 304 times.
✗ Branch 1 not taken.
304 temp_cauto.addEntry(ca_cid, ca_ctype, q, -1);
18507 304 }
18508
18509
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 combo_autos[ca] = temp_cauto;
18510 24 }
18511
18512 112 return 0;
18513 112 }
18514
18515 128 int32_t readcolordata(PACKFILE *f, miscQdata *Misc, word version, word build, word start_cset, word max_csets)
18516 {
18517
2/2
✓ Branch 0 taken 124 times.
✓ Branch 1 taken 4 times.
128 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_colors);
18518
18519 //these are here to bypass compiler warnings about unused arguments
18520 //THE *48 REFERS TO EACH CSET BEING 16 COLORS with 3 VALUES OF RGB (3*16 is 48)
18521 //Capitalized cause it'll save you a headache. -Deedee
18522 128 start_cset=start_cset;
18523 128 max_csets=max_csets;
18524 128 word s_version=0;
18525
18526 miscQdata temp_misc;
18527 128 memcpy(&temp_misc, Misc, sizeof(temp_misc));
18528
18529 byte temp_colordata[48];
18530 char temp_palname[PALNAMESIZE+1];
18531
18532 int32_t dummy;
18533 word palcycles;
18534
18535
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 124 times.
128 if(version > 0x192)
18536 {
18537 //section version info
18538
1/2
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
124 if(!p_igetw(&s_version,f))
18539 {
18540 return qe_invalid;
18541 }
18542
18543 124 FFCore.quest_format[vCSets] = s_version;
18544
18545 //al_trace("Color data version %d\n", s_version);
18546
1/2
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
124 if(!p_igetw(&dummy,f))
18547 {
18548 return qe_invalid;
18549 }
18550
18551 //section size
18552
1/2
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
124 if(!p_igetl(&dummy,f))
18553 {
18554 return qe_invalid;
18555 }
18556 124 }
18557
2/2
✓ Branch 0 taken 93 times.
✓ Branch 1 taken 35 times.
128 if (s_version < 5)
18558 {
18559
3/4
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 89 times.
✓ Branch 2 taken 89 times.
✗ Branch 3 not taken.
93 bool RealOldVerion = ((version < 0x192)||((version == 0x192)&&(build<73)));
18560
18561 //finally... section data
18562 93 int32_t q = 0;
18563 93 int32_t p = -15;
18564
2/2
✓ Branch 0 taken 22320 times.
✓ Branch 1 taken 93 times.
22413 for(int32_t i=0; i<oldpdTOTAL; ++i)
18565 {
18566 22320 memset(temp_colordata, 0, 48);
18567
18568
1/2
✓ Branch 0 taken 22320 times.
✗ Branch 1 not taken.
22320 if(!pfread(temp_colordata,48,f))
18569 {
18570 return qe_invalid;
18571 }
18572
18573
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22320 times.
22320 if (should_skip)
18574 continue;
18575
18576 22320 memcpy(&colordata[q*48], temp_colordata, 48);
18577
18578 22320 ++q;
18579
8/8
✓ Branch 0 taken 20832 times.
✓ Branch 1 taken 1488 times.
✓ Branch 2 taken 1581 times.
✓ Branch 3 taken 19251 times.
✓ Branch 4 taken 186 times.
✓ Branch 5 taken 1395 times.
✓ Branch 6 taken 8 times.
✓ Branch 7 taken 178 times.
22320 if (p > 0 && (p%13)==12 && (i < oldpoSPRITE || !RealOldVerion)) //It's > 0 instead of >= 0 because it should append
18580 {
18581
1/2
✓ Branch 0 taken 1573 times.
✗ Branch 1 not taken.
1573 if (s_version < 5) //Bumping up the size of level palettes
18582 {
18583 1573 memcpy(&colordata[(q)*48], &colordata[1*48], 48);
18584 1573 memcpy(&colordata[(q+1)*48], &colordata[5*48], 48);
18585 1573 memcpy(&colordata[(q+2)*48], &colordata[7*48], 48);
18586 1573 memcpy(&colordata[(q+3)*48], &colordata[8*48], 48);
18587 1573 q+=4;
18588 1573 }
18589 else
18590 {
18591 for(int m = 0; m < 4; ++m)
18592 {
18593 memset(temp_colordata, 0, 48);
18594 if(!pfread(temp_colordata,48,f))
18595 {
18596 return qe_invalid;
18597 }
18598 memcpy(&colordata[q*48], temp_colordata, 48);
18599 ++q;
18600 }
18601 }
18602 1573 }
18603 22320 ++p;
18604 22320 }
18605
18606
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 89 times.
93 if(RealOldVerion)
18607 {
18608
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if (!should_skip)
18609 {
18610 4 memcpy(colordata+(poSPRITE255*48), colordata+((q-30)*48), 30*16*3);
18611 4 memset(colordata+((q-30)*48), 0, ((poSPRITE255-(q-30))*48));
18612 4 memcpy(colordata+((poSPRITE255+11)*48), colordata+((poSPRITE255+10)*48), 48);
18613 4 memcpy(colordata+((poSPRITE255+10)*48), colordata+((poSPRITE255+9)*48), 48);
18614 4 memcpy(colordata+((poSPRITE255+9)*48), colordata+((poSPRITE255+8)*48), 48);
18615 4 memset(colordata+((poSPRITE255+8)*48), 0, 48);
18616 4 }
18617 4 }
18618 else
18619 {
18620 89 memset(temp_colordata, 0, 48);
18621
18622
2/2
✓ Branch 0 taken 278837 times.
✓ Branch 1 taken 89 times.
278926 for(int32_t i=0; i<newpdTOTAL-oldpdTOTAL; ++i)
18623 {
18624
1/2
✓ Branch 0 taken 278837 times.
✗ Branch 1 not taken.
278837 if(!pfread(temp_colordata,48,f))
18625 {
18626 return qe_invalid;
18627 }
18628
18629
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 278837 times.
278837 if (should_skip)
18630 continue;
18631
18632 278837 memcpy(&colordata[q*48], temp_colordata, 48);
18633
18634 278837 ++q;
18635
7/8
✓ Branch 0 taken 278837 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 21449 times.
✓ Branch 3 taken 257388 times.
✓ Branch 4 taken 178 times.
✓ Branch 5 taken 21271 times.
✓ Branch 6 taken 154 times.
✓ Branch 7 taken 24 times.
278837 if (p > 0 && (p%13)==12 && (i < (newpoSPRITE-oldpdTOTAL) || (s_version >= 4))) //It's > 0 instead of >= 0 because it should append
18636 {
18637
1/2
✓ Branch 0 taken 21425 times.
✗ Branch 1 not taken.
21425 if (s_version < 5) //Bumping up the size of level palettes
18638 {
18639 21425 memcpy(&colordata[(q)*48], &colordata[1*48], 48);
18640 21425 memcpy(&colordata[(q+1)*48], &colordata[5*48], 48);
18641 21425 memcpy(&colordata[(q+2)*48], &colordata[7*48], 48);
18642 21425 memcpy(&colordata[(q+3)*48], &colordata[8*48], 48);
18643 21425 q+=4;
18644 21425 }
18645 else
18646 {
18647 for(int m = 0; m < 4; ++m)
18648 {
18649 memset(temp_colordata, 0, 48);
18650 if(!pfread(temp_colordata,48,f))
18651 {
18652 return qe_invalid;
18653 }
18654 memcpy(&colordata[q*48], temp_colordata, 48);
18655 ++q;
18656 }
18657 }
18658 21425 }
18659 278837 ++p;
18660 278837 }
18661
18662
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 77 times.
89 if(s_version < 4)
18663 {
18664
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if (!should_skip)
18665 {
18666 12 memcpy(colordata+(poSPRITE255*48), colordata+((q-30)*48), 30*16*3);
18667 12 memset(colordata+((q-30)*48), 0, ((poSPRITE255-(q-30))*48));
18668 12 }
18669 12 }
18670 else
18671 {
18672
2/2
✓ Branch 0 taken 256256 times.
✓ Branch 1 taken 77 times.
256333 for(int32_t i=0; i<newerpdTOTAL-newpdTOTAL; ++i)
18673 {
18674
1/2
✓ Branch 0 taken 256256 times.
✗ Branch 1 not taken.
256256 if(!pfread(temp_colordata,48,f))
18675 {
18676 return qe_invalid;
18677 }
18678
18679
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 256256 times.
256256 if (should_skip)
18680 continue;
18681
18682 256256 memcpy(&colordata[q*48], temp_colordata, 48);
18683 256256 ++q;
18684
5/6
✓ Branch 0 taken 256256 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 19712 times.
✓ Branch 3 taken 236544 times.
✓ Branch 4 taken 154 times.
✓ Branch 5 taken 19558 times.
256256 if (p > 0 && (p%13)==12 && i < newerpoSPRITE-newpdTOTAL) //It's > 0 instead of >= 0 because it should append
18685 {
18686
1/2
✓ Branch 0 taken 19558 times.
✗ Branch 1 not taken.
19558 if (s_version < 5) //Bumping up the size of level palettes
18687 {
18688 19558 memcpy(&colordata[(q)*48], &colordata[1*48], 48);
18689 19558 memcpy(&colordata[(q+1)*48], &colordata[5*48], 48);
18690 19558 memcpy(&colordata[(q+2)*48], &colordata[7*48], 48);
18691 19558 memcpy(&colordata[(q+3)*48], &colordata[8*48], 48);
18692 19558 q+=4;
18693 19558 }
18694 else
18695 {
18696 for(int m = 0; m < 4; ++m)
18697 {
18698 memset(temp_colordata, 0, 48);
18699 if(!pfread(temp_colordata,48,f))
18700 {
18701 return qe_invalid;
18702 }
18703 memcpy(&colordata[q*48], temp_colordata, 48);
18704 ++q;
18705 }
18706 }
18707 19558 }
18708 256256 ++p;
18709 256256 }
18710
18711 //By this point, q should be about equal to pdTOTAL255. If it isn't, I've fucked up. -Deedee
18712 }
18713 }
18714 93 }
18715 else
18716 {
18717
2/2
✓ Branch 0 taken 306215 times.
✓ Branch 1 taken 35 times.
306250 for(int32_t i=0; i<pdTOTAL255; ++i)
18718 {
18719 306215 memset(temp_colordata, 0, 48);
18720
18721
1/2
✓ Branch 0 taken 306215 times.
✗ Branch 1 not taken.
306215 if(!pfread(temp_colordata,48,f))
18722 {
18723 return qe_invalid;
18724 }
18725
18726 306215 memcpy(&colordata[i*48], temp_colordata, 48);
18727 306215 }
18728 }
18729
18730
3/6
✓ Branch 0 taken 124 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 124 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
128 if((version < 0x192)||((version == 0x192)&&(build<76)))
18731 {
18732
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if (!should_skip)
18733 4 init_palnames();
18734 4 }
18735 else
18736 {
18737 124 int32_t palnamestoread = 0;
18738
18739
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 112 times.
124 if(s_version < 3)
18740 12 palnamestoread = OLDMAXLEVELS;
18741 else
18742 112 palnamestoread = 512;
18743
18744
2/2
✓ Branch 0 taken 60416 times.
✓ Branch 1 taken 124 times.
60540 for(int32_t i=0; i<palnamestoread; ++i)
18745 {
18746
1/2
✓ Branch 0 taken 60416 times.
✗ Branch 1 not taken.
60416 if(!p_getstr(temp_palname,PALNAMESIZE,f))
18747 {
18748 return qe_invalid;
18749 }
18750
18751
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 60416 times.
60416 if (!should_skip)
18752 60416 memcpy(palnames[i], temp_palname, PALNAMESIZE);
18753 60416 }
18754
18755
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 124 times.
124 if (should_skip)
18756 return 0;
18757
18758
2/2
✓ Branch 0 taken 3072 times.
✓ Branch 1 taken 124 times.
3196 for(int32_t i=palnamestoread; i<MAXLEVELS; i++)
18759 {
18760 3072 memset(palnames[i], 0, PALNAMESIZE);
18761 3072 }
18762 }
18763
18764
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 124 times.
128 if(version > 0x192)
18765 {
18766
2/2
✓ Branch 0 taken 31744 times.
✓ Branch 1 taken 124 times.
31868 for(int32_t i=0; i<256; i++)
18767 {
18768
2/2
✓ Branch 0 taken 95232 times.
✓ Branch 1 taken 31744 times.
126976 for(int32_t j=0; j<3; j++)
18769 {
18770 95232 temp_misc.cycles[i][j].first=0;
18771 95232 temp_misc.cycles[i][j].count=0;
18772 95232 temp_misc.cycles[i][j].speed=0;
18773 95232 }
18774 31744 }
18775
18776
1/2
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
124 if(!p_igetw(&palcycles,f))
18777 {
18778 return qe_invalid;
18779 }
18780
18781
2/4
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 124 times.
124 if (!(palcycles >= 0 && palcycles <= NUM_PAL_CYCLES))
18782 {
18783 return qe_invalid;
18784 }
18785
18786
2/2
✓ Branch 0 taken 3576 times.
✓ Branch 1 taken 124 times.
3700 for(int32_t i=0; i<palcycles; i++)
18787 {
18788
2/2
✓ Branch 0 taken 10728 times.
✓ Branch 1 taken 3576 times.
14304 for(int32_t j=0; j<3; j++)
18789 {
18790
1/2
✓ Branch 0 taken 10728 times.
✗ Branch 1 not taken.
10728 if(!p_getc(&temp_misc.cycles[i][j].first,f))
18791 {
18792 return qe_invalid;
18793 }
18794 10728 }
18795
18796
2/2
✓ Branch 0 taken 10728 times.
✓ Branch 1 taken 3576 times.
14304 for(int32_t j=0; j<3; j++)
18797 {
18798
1/2
✓ Branch 0 taken 10728 times.
✗ Branch 1 not taken.
10728 if(!p_getc(&temp_misc.cycles[i][j].count,f))
18799 {
18800 return qe_invalid;
18801 }
18802 10728 }
18803
18804
2/2
✓ Branch 0 taken 10728 times.
✓ Branch 1 taken 3576 times.
14304 for(int32_t j=0; j<3; j++)
18805 {
18806
1/2
✓ Branch 0 taken 10728 times.
✗ Branch 1 not taken.
10728 if(!p_getc(&temp_misc.cycles[i][j].speed,f))
18807 {
18808 return qe_invalid;
18809 }
18810 10728 }
18811 3576 }
18812
18813 124 memcpy(Misc, &temp_misc, sizeof(temp_misc));
18814 124 }
18815
18816 128 return 0;
18817 128 }
18818
18819 128 int32_t readtiles(PACKFILE *f, tiledata *buf, zquestheader *Header, word version, word build, word start_tile, int32_t max_tiles, bool from_init)
18820 {
18821
2/2
✓ Branch 0 taken 124 times.
✓ Branch 1 taken 4 times.
128 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_tiles);
18822
18823 128 int32_t tiles_used=0;
18824 128 word section_version = 0;
18825 128 word section_cversion = 0;
18826 128 int32_t section_size= 0;
18827 128 byte *temp_tile = new byte[tilesize(tf32Bit)];
18828
18829 //Tile Expansion
18830 //if ( version >= 0x254 && build >= 41 )
18831
3/4
✓ Branch 0 taken 93 times.
✓ Branch 1 taken 35 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 93 times.
128 if (version < 0x254 && build < 41)
18832 {
18833 //al_trace("Build was < 41 when reading tiles\n");
18834 93 max_tiles = ZC250MAXTILES;
18835 93 }
18836
18837 //al_trace("Max Tiles: %d\n", max_tiles);
18838
18839
2/6
✓ Branch 0 taken 128 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 128 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
128 if(Header!=NULL&&(!Header->data_flags[ZQ_TILES]&&!from_init)) //keep for old quests
18840 {
18841 if(!init_tiles(true, Header))
18842 {
18843 al_trace("Unable to initialize tiles\n");
18844 }
18845
18846 delete[] temp_tile;
18847 temp_tile=NULL;
18848 return 0;
18849 }
18850 else
18851 {
18852
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 124 times.
128 if(version > 0x192)
18853 {
18854 //section version info
18855
1/2
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
124 if(!p_igetw(&section_version,f))
18856 {
18857 delete[] temp_tile;
18858 return qe_invalid;
18859 }
18860
18861 124 FFCore.quest_format[vTiles] = section_version;
18862
18863
1/2
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
124 if(!p_igetw(&section_cversion,f))
18864 {
18865 delete[] temp_tile;
18866 return qe_invalid;
18867 }
18868
18869 //section size
18870
1/2
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
124 if(!p_igetl(&section_size,f))
18871 {
18872 delete[] temp_tile;
18873 return qe_invalid;
18874 }
18875 124 }
18876
18877 //if ( build < 41 )
18878 //{
18879 // tiles_used = ZC250MAXTILES;
18880 //}
18881
18882
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 128 times.
128 if(version < 0x174)
18883 {
18884 tiles_used=TILES_PER_PAGE*4;
18885 } //no expanded tile space
18886
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 124 times.
128 else if(version < 0x191)
18887 {
18888 4 tiles_used=OLDMAXTILES;
18889 4 }
18890 else
18891 {
18892 //finally... section data
18893
3/4
✓ Branch 0 taken 35 times.
✓ Branch 1 taken 89 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 35 times.
124 if ( version >= 0x254 && build >= 41 ) //read and write the size of tiles_used properly
18894 {
18895
1/2
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
35 if(!p_igetl(&tiles_used,f))
18896 {
18897 delete[] temp_tile;
18898 return qe_invalid;
18899 }
18900 35 }
18901 else
18902 {
18903
1/2
✓ Branch 0 taken 89 times.
✗ Branch 1 not taken.
89 if(!p_igetw(&tiles_used,f))
18904 {
18905 delete[] temp_tile;
18906 return qe_invalid;
18907 }
18908 }
18909 }
18910
18911
1/2
✓ Branch 0 taken 128 times.
✗ Branch 1 not taken.
128 tiles_used=zc_min(tiles_used, max_tiles);
18912
18913 //if ( version < 0x254 || ( version >= 0x254 && build < 41 )) //don't do this, it crashes ZQuest. -Z
18914 //if ( version < 0x254 && build < 41 )
18915
3/6
✓ Branch 0 taken 35 times.
✓ Branch 1 taken 93 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 35 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
128 if ( version < 0x254 || (version == 0x254 && build < 41) )
18916 //if ( build < 41 )
18917 {
18918
1/2
✓ Branch 0 taken 93 times.
✗ Branch 1 not taken.
93 tiles_used=zc_min(tiles_used, ZC250MAXTILES-start_tile);
18919 93 }
18920 else //2.55
18921 {
18922
1/2
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
35 tiles_used = zc_min(tiles_used,NEWMAXTILES-start_tile);
18923 }
18924
18925 //if ( section_version > 1 ) tiles_used = NEWMAXTILES;
18926
18927 //al_trace("tiles_used = %d\n", tiles_used);
18928
18929
2/2
✓ Branch 0 taken 3457746 times.
✓ Branch 1 taken 128 times.
3457874 for(int32_t i=0; i<tiles_used; ++i)
18930 {
18931 3457746 byte format=tf4Bit;
18932 3457746 memset(temp_tile, 0, tilesize(tf32Bit));
18933
18934
3/6
✓ Branch 0 taken 630780 times.
✓ Branch 1 taken 2826966 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 630780 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
3457746 if((version>0x211)||((version==0x211)&&(build>4)))
18935 {
18936
1/2
✓ Branch 0 taken 2826966 times.
✗ Branch 1 not taken.
2826966 if(!p_getc(&format,f))
18937 {
18938 delete[] temp_tile;
18939 return qe_invalid;
18940 }
18941 2826966 }
18942
4/4
✓ Branch 0 taken 1277412 times.
✓ Branch 1 taken 2180334 times.
✓ Branch 2 taken 592329 times.
✓ Branch 3 taken 685083 times.
3457746 if(section_version > 2 && !format)
18943 {
18944 685083 reset_tile(buf,start_tile+i,tf4Bit);
18945 685083 continue;
18946 }
18947
18948
1/2
✓ Branch 0 taken 2772663 times.
✗ Branch 1 not taken.
2772663 if(!pfread(temp_tile,tilesize(format),f))
18949 {
18950 delete[] temp_tile;
18951 return qe_invalid;
18952 }
18953
18954
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2772663 times.
2772663 if (should_skip)
18955 continue;
18956
18957 2772663 buf[start_tile+i].format=format;
18958
18959
1/2
✓ Branch 0 taken 2772663 times.
✗ Branch 1 not taken.
2772663 if(buf[start_tile+i].data)
18960 {
18961 2772663 free(buf[start_tile+i].data);
18962 2772663 buf[start_tile+i].data=NULL;
18963 2772663 }
18964
18965 2772663 buf[start_tile+i].data=(byte *)malloc(tilesize(buf[start_tile+i].format));
18966 2772663 memcpy(buf[start_tile+i].data,temp_tile,tilesize(buf[start_tile+i].format));
18967 2772663 }
18968 }
18969
18970
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 128 times.
128 if (should_skip)
18971 return 0;
18972
18973
2/2
✓ Branch 0 taken 35 times.
✓ Branch 1 taken 93 times.
128 if ( section_version < 2 ) //write blank tile data --check s_version with this again instead?
18974 {
18975 //al_trace("Writing blank tile data to new tiles for build < 41\n");
18976
2/2
✓ Branch 0 taken 13855140 times.
✓ Branch 1 taken 93 times.
13855233 for ( int32_t q = ZC250MAXTILES; q < NEWMAXTILES; ++q )
18977 {
18978
18979 //memcpy(buf[q].data,temp_tile,tilesize(buf[q].format));
18980 13855140 reset_tile(buf,q,tf4Bit);
18981
18982
18983 /*
18984
18985 byte tempbyte;
18986 for(int32_t i=0; i<tilesize(tf4Bit); i++)
18987 {
18988 tempbyte=buf[ZC250MAXTILES-1].data[i];
18989 buf[q].data[i] = tempbyte;
18990 }
18991 //int32_t temp = tempbyte=buf[130].data[i];
18992 //buf[q].data = buf[ZC250MAXTILES-1].data;
18993 */
18994 //reset_tile(buf,q,tf4Bit);
18995 13855140 }
18996
18997 93 }
18998
18999
4/6
✓ Branch 0 taken 35 times.
✓ Branch 1 taken 93 times.
✓ Branch 2 taken 35 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 35 times.
128 if ( version < 0x254 || ( version >= 0x254 && build < 41 ))
19000 {
19001
2/2
✓ Branch 0 taken 4121646 times.
✓ Branch 1 taken 93 times.
4121739 for(int32_t i=start_tile+tiles_used; i<max_tiles; ++i)
19002 {
19003 //al_trace("Resetting tiles for ZC250MAXTILES, iteration: %d\n", i);
19004 4121646 reset_tile(buf,i,tf4Bit);
19005 4121646 }
19006 93 }
19007 else
19008 {
19009
2/2
✓ Branch 0 taken 6021468 times.
✓ Branch 1 taken 35 times.
6021503 for(int32_t i=start_tile+tiles_used; i<max_tiles; ++i)
19010 {
19011 //al_trace("Resetting tiles for build 41+\n");
19012 6021468 reset_tile(buf,i,tf4Bit);
19013 6021468 }
19014 }
19015
19016
3/6
✓ Branch 0 taken 124 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 124 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
128 if((version < 0x192)|| ((version == 0x192)&&(build<186)))
19017 {
19018
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(get_qr(qr_BSZELDA)) //
19019 {
19020 byte tempbyte;
19021 int32_t floattile=wpnsbuf[iwSwim].tile;
19022
19023 for(int32_t i=0; i<tilesize(tf4Bit); i++) //BSZelda tiles are out of order //does this include swim tiles?
19024 {
19025 tempbyte=buf[23].data[i];
19026 buf[23].data[i]=buf[24].data[i];
19027 buf[24].data[i]=buf[25].data[i];
19028 buf[25].data[i]=buf[26].data[i];
19029 buf[26].data[i]=tempbyte;
19030 }
19031 //swim tiles are out of order, too, but nobody cared? -Z
19032 for(int32_t i=0; i<tilesize(tf4Bit); i++)
19033 {
19034 tempbyte=buf[floattile+11].data[i];
19035 buf[floattile+11].data[i]=buf[floattile+12].data[i];
19036 buf[floattile+12].data[i]=tempbyte;
19037 }
19038 }
19039 4 }
19040
19041
3/6
✓ Branch 0 taken 112 times.
✓ Branch 1 taken 16 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 112 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
128 if((version < 0x211)||((version == 0x211)&&(build<7))) //Goriya tiles are out of order
19042 {
19043
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 4 times.
16 if(!get_qr(qr_NEWENEMYTILES))
19044 {
19045 byte tempbyte;
19046
19047
2/2
✓ Branch 0 taken 512 times.
✓ Branch 1 taken 4 times.
516 for(int32_t i=0; i<tilesize(tf4Bit); i++)
19048 {
19049 512 tempbyte=buf[130].data[i];
19050 512 buf[130].data[i]=buf[132].data[i];
19051 512 buf[132].data[i]=tempbyte;
19052
19053 512 tempbyte=buf[131].data[i];
19054 512 buf[131].data[i]=buf[133].data[i];
19055 512 buf[133].data[i]=tempbyte;
19056 512 }
19057 4 }
19058 16 }
19059
19060 128 al_trace("Registering blank tiles\n");
19061 128 register_blank_tiles();
19062
19063 //memset(temp_tile, 0, tilesize(tf32Bit));
19064
1/2
✓ Branch 0 taken 128 times.
✗ Branch 1 not taken.
128 delete[] temp_tile;
19065 128 temp_tile=NULL;
19066 128 return 0;
19067 128 }
19068
19069 128 int32_t readtunes(PACKFILE *f, zquestheader *Header, zctune *tunes /*zcmidi_ *midis*/)
19070 {
19071
2/2
✓ Branch 0 taken 124 times.
✓ Branch 1 taken 4 times.
128 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_midis);
19072
19073 static byte fake_midi_flags[32];
19074
19075
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 128 times.
128 byte *mf=should_skip ? fake_midi_flags : midi_flags;
19076 int32_t dummy;
19077 word dummy2;
19078 // zcmidi_ temp_midi;
19079 int32_t tunes_to_read;
19080 128 int32_t tune_count=0;
19081 128 word section_version=0;
19082 128 zctune temp;
19083
19084
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 124 times.
128 if(Header->zelda_version < 0x193)
19085 {
19086 // mf=Header->data_flags+ZQ_MIDIS2;
19087
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
4 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<178)))
19088 {
19089 4 tunes_to_read=MAXCUSTOMMIDIS192b177;
19090 4 }
19091 else
19092 {
19093 tunes_to_read=MAXCUSTOMTUNES;
19094 }
19095 4 }
19096 else
19097 {
19098 //section version info
19099
1/2
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
124 if(!p_igetw(&section_version,f))
19100 {
19101 return qe_invalid;
19102 }
19103
19104
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 124 times.
124 if (!should_skip)
19105 124 FFCore.quest_format[vMIDIs] = section_version;
19106
19107 //al_trace("Tunes version %d\n", section_version);
19108
1/2
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
124 if(!p_igetw(&dummy2,f))
19109 {
19110 return qe_invalid;
19111 }
19112
19113 //section size
19114
1/2
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
124 if(!p_igetl(&dummy,f))
19115 {
19116 return qe_invalid;
19117 }
19118
19119 //finally... section data
19120
1/2
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
124 if(!pfread(midi_flags,sizeof(midi_flags),f))
19121 {
19122 return qe_invalid;
19123 }
19124
19125 124 tunes_to_read=MAXCUSTOMTUNES;
19126 }
19127
19128
2/2
✓ Branch 0 taken 32256 times.
✓ Branch 1 taken 128 times.
32384 for(int32_t i=0; i<MAXCUSTOMTUNES; ++i)
19129 {
19130
2/2
✓ Branch 0 taken 2301 times.
✓ Branch 1 taken 29955 times.
32256 if(get_bit(mf, i))
19131 {
19132 2301 ++tune_count;
19133 2301 }
19134 32256 }
19135
19136
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 128 times.
128 if (!should_skip)
19137 128 reset_tunes(tunes); //reset_midis(midis);
19138
19139
2/2
✓ Branch 0 taken 31376 times.
✓ Branch 1 taken 128 times.
31504 for(int32_t i=0; i<tunes_to_read; i++)
19140 {
19141 31376 temp.clear(); //memset(&temp_midi,0,sizeof(zcmidi_));
19142
19143
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 31376 times.
31376 if (!should_skip)
19144 31376 tunes[i].reset(); // reset_midi(midis+i);
19145
19146
2/2
✓ Branch 0 taken 29075 times.
✓ Branch 1 taken 2301 times.
31376 if(get_bit(mf,i))
19147 {
19148
2/2
✓ Branch 0 taken 717 times.
✓ Branch 1 taken 1584 times.
2301 if(section_version < 4)
19149 {
19150
1/2
✓ Branch 0 taken 717 times.
✗ Branch 1 not taken.
717 if(!p_getstr(temp.title,20,f))
19151 {
19152 return qe_invalid;
19153 }
19154 717 }
19155 else
19156 {
19157
1/2
✓ Branch 0 taken 1584 times.
✗ Branch 1 not taken.
1584 if(!p_getstr(temp.title,sizeof(temp.title)-1,f))
19158 {
19159 return qe_invalid;
19160 }
19161 }
19162
19163
1/2
✓ Branch 0 taken 2301 times.
✗ Branch 1 not taken.
2301 if(!p_igetl(&temp.start,f))
19164 {
19165 return qe_invalid;
19166 }
19167
19168
1/2
✓ Branch 0 taken 2301 times.
✗ Branch 1 not taken.
2301 if(!p_igetl(&temp.loop_start,f))
19169 {
19170 return qe_invalid;
19171 }
19172
19173
1/2
✓ Branch 0 taken 2301 times.
✗ Branch 1 not taken.
2301 if(!p_igetl(&temp.loop_end,f))
19174 {
19175 return qe_invalid;
19176 }
19177
19178
1/2
✓ Branch 0 taken 2301 times.
✗ Branch 1 not taken.
2301 if(!p_igetw(&temp.loop,f))
19179 {
19180 return qe_invalid;
19181 }
19182
19183
1/2
✓ Branch 0 taken 2301 times.
✗ Branch 1 not taken.
2301 if(!p_igetw(&temp.volume,f))
19184 {
19185 return qe_invalid;
19186 }
19187
19188
2/2
✓ Branch 0 taken 2223 times.
✓ Branch 1 taken 78 times.
2301 if(Header->zelda_version < 0x193)
19189 {
19190
1/2
✓ Branch 0 taken 78 times.
✗ Branch 1 not taken.
78 if(!p_igetl(&dummy,f))
19191 {
19192 return qe_invalid;
19193 }
19194 78 }
19195
19196
2/2
✓ Branch 0 taken 717 times.
✓ Branch 1 taken 1584 times.
2301 if(section_version >= 3)
19197 {
19198
1/2
✓ Branch 0 taken 1584 times.
✗ Branch 1 not taken.
1584 if(!pfread(&temp.flags,sizeof(temp.flags),f))
19199 {
19200 return qe_invalid;
19201 }
19202 1584 }
19203
19204
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2301 times.
2301 if (!should_skip)
19205 2301 tunes[i].copyfrom(temp); // memcpy(&midis[i], &temp_midi, sizeof(zcmidi_));
19206
19207
2/2
✓ Branch 0 taken 717 times.
✓ Branch 1 taken 1584 times.
2301 if(section_version < 2) //= 1 || (Header->zelda_version < 0x211) || (Header->zelda_version == 0x211 && Header->build < 18))
19208 {
19209
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 717 times.
717 if (should_skip)
19210 {
19211 if (read_midi(f)==NULL)
19212 {
19213 return qe_invalid;
19214 }
19215
19216 continue;
19217 }
19218
19219 // old format - a midi is a midi
19220
1/2
✓ Branch 0 taken 717 times.
✗ Branch 1 not taken.
717 if((tunes[i].data=read_midi(f))==NULL)
19221 {
19222 return qe_invalid;
19223 }
19224
19225 //yes you can do this. Isn't the ? operator awesome? :)
19226 717 tunes[i].format = MFORMAT_MIDI;
19227 717 }
19228 else
19229 {
19230 // 'midi' could be midi or nes, gb, ... music
19231
1/2
✓ Branch 0 taken 1584 times.
✗ Branch 1 not taken.
1584 if(!pfread(&tunes[i].format,sizeof(tunes[i].format),f))
19232 {
19233 return qe_invalid;
19234 }
19235
19236 1584 zctune *ptr = &tunes[i];
19237
19238
1/2
✓ Branch 0 taken 1584 times.
✗ Branch 1 not taken.
1584 switch(temp.format)
19239 {
19240 case MFORMAT_MIDI:
19241
1/2
✓ Branch 0 taken 1584 times.
✗ Branch 1 not taken.
1584 if((ptr->data=read_midi(f))==NULL)
19242 {
19243 return qe_invalid;
19244 }
19245
19246 1584 break;
19247
19248 default:
19249 return qe_invalid;
19250 break;
19251 }
19252 }
19253 2301 }
19254 31376 }
19255
19256 128 return 0;
19257 128 }
19258
19259 128 int32_t readcheatcodes(PACKFILE *f, zquestheader *Header)
19260 {
19261
2/2
✓ Branch 0 taken 124 times.
✓ Branch 1 taken 4 times.
128 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_cheats);
19262
19263 int32_t dummy;
19264 ZCHEATS tempzcheats;
19265 128 char temp_use_cheats=1;
19266 128 memset(&tempzcheats, 0, sizeof(tempzcheats));
19267 128 word s_version = 0;
19268
19269
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 124 times.
128 if(Header->zelda_version > 0x192)
19270 {
19271 //section version info
19272
1/2
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
124 if(!p_igetw(&s_version,f))
19273 {
19274 return qe_invalid;
19275 }
19276
19277 124 FFCore.quest_format[vCheats] = s_version;
19278 //al_trace("Cheats version %d\n", dummy);
19279
1/2
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
124 if(!p_igetw(&dummy,f))
19280 {
19281 return qe_invalid;
19282 }
19283
19284 //section size
19285
1/2
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
124 if(!p_igetl(&dummy,f))
19286 {
19287 return qe_invalid;
19288 }
19289
19290 //finally... section data
19291
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 124 times.
124 if(!p_getc(&temp_use_cheats,f))
19292 {
19293 return qe_invalid;
19294 }
19295 124 }
19296
19297
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 128 times.
128 if(Header->data_flags[ZQ_CHEATS2])
19298 {
19299
1/2
✓ Branch 0 taken 128 times.
✗ Branch 1 not taken.
128 if(!p_igetl(&tempzcheats.flags,f))
19300 {
19301 return qe_invalid;
19302 }
19303
19304
1/2
✓ Branch 0 taken 128 times.
✗ Branch 1 not taken.
128 if(!pfread(&tempzcheats.codes, sizeof(tempzcheats.codes),f))
19305 {
19306 return qe_invalid;
19307 }
19308 128 }
19309
19310
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 128 times.
128 if (should_skip)
19311 return 0;
19312
19313 128 memcpy(&zcheats, &tempzcheats, sizeof(tempzcheats));
19314 128 Header->data_flags[ZQ_CHEATS2]=temp_use_cheats;
19315
19316 128 return 0;
19317 128 }
19318
19319 120 int32_t readinitdata_old(PACKFILE *f, zquestheader *Header, word s_version, word s_cversion, zinitdata& temp_zinit)
19320 {
19321
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 116 times.
120 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_initdata);
19322
19323 int32_t dummy;
19324 byte padding, tempbyte;
19325
19326 // Legacy item properties (now integrated into itemdata)
19327 byte sword_hearts[4];
19328 byte beam_hearts[4];
19329 120 byte beam_percent=0;
19330 word beam_power[4];
19331 120 byte hookshot_length=99;
19332 120 byte hookshot_links=100;
19333 120 byte longshot_length=99;
19334 120 byte longshot_links=100;
19335 120 byte moving_fairy_hearts=3;
19336 120 byte moving_fairy_heart_percent=0;
19337 120 byte stationary_fairy_hearts=3;
19338 120 byte stationary_fairy_heart_percent=0;
19339 120 byte moving_fairy_magic=0;
19340 120 byte moving_fairy_magic_percent=0;
19341 120 byte stationary_fairy_magic=0;
19342 120 byte stationary_fairy_magic_percent=0;
19343 120 byte blue_potion_hearts=100;
19344 120 byte blue_potion_heart_percent=1;
19345 120 byte red_potion_hearts=100;
19346 120 byte red_potion_heart_percent=1;
19347 120 byte blue_potion_magic=100;
19348 120 byte blue_potion_magic_percent=1;
19349 120 byte red_potion_magic=100;
19350 120 byte red_potion_magic_percent=1;
19351
19352 120 byte bomb_ratio = 4;
19353
19354 120 subscr_mode = 0;
19355
19356 /* HIGHLY UNORTHODOX UPDATING THING, by L
19357 * This fixes quests made before revision 277 (such as the 'Lost Isle Build'),
19358 * where the speed of Pols Voice changed. It also coincided with V_INITDATA
19359 * changing from 13 to 14.
19360 */
19361
2/2
✓ Branch 0 taken 104 times.
✓ Branch 1 taken 16 times.
120 if(s_version < 14)
19362 16 fixpolsvoice=true;
19363
19364 /* End highly unorthodox updating thing */
19365
19366
4/4
✓ Branch 0 taken 104 times.
✓ Branch 1 taken 16 times.
✓ Branch 2 taken 75 times.
✓ Branch 3 taken 29 times.
120 if(s_version >= 15 && get_bit(deprecated_rules, 27)) // The int16_t-lived rule, qr_JUMPHEROLAYER3
19367 29 temp_zinit.jump_hero_layer_threshold=0;
19368
19369
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 104 times.
120 if(s_version >= 10)
19370 {
19371 char temp;
19372
19373 //new-style items
19374
2/2
✓ Branch 0 taken 26624 times.
✓ Branch 1 taken 104 times.
26728 for(int32_t j=0; j<256; j++)
19375 {
19376
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 26624 times.
26624 if(!p_getc(&temp,f))
19377 return qe_invalid;
19378
19379 26624 temp_zinit.set_item(j, temp != 0);
19380 26624 }
19381 104 }
19382
19383
3/6
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 116 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
120 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>26)))
19384 {
19385 char temp;
19386
19387 //finally... section data
19388
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 116 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
116 if((Header->zelda_version > 0x192)||
19389 //new only
19390 ((Header->zelda_version == 0x192)&&(Header->build>173)))
19391 {
19392 //OLD-style items... sigh
19393
2/2
✓ Branch 0 taken 104 times.
✓ Branch 1 taken 12 times.
116 if(s_version < 10)
19394 {
19395
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!p_getc(&temp,f))
19396 {
19397 return qe_invalid;
19398 }
19399
19400 12 temp_zinit.set_item(iRaft, temp != 0);
19401
19402
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!p_getc(&temp,f))
19403 {
19404 return qe_invalid;
19405 }
19406
19407 12 temp_zinit.set_item(iLadder, temp != 0);
19408
19409
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!p_getc(&temp,f))
19410 {
19411 return qe_invalid;
19412 }
19413
19414 12 temp_zinit.set_item(iBook, temp != 0);
19415
19416
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!p_getc(&temp,f))
19417 {
19418 return qe_invalid;
19419 }
19420
19421 12 temp_zinit.set_item(iMKey, temp != 0);
19422
19423
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!p_getc(&temp,f))
19424 {
19425 return qe_invalid;
19426 }
19427
19428 12 temp_zinit.set_item(iFlippers, temp != 0);
19429
19430
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!p_getc(&temp,f))
19431 {
19432 return qe_invalid;
19433 }
19434
19435 12 temp_zinit.set_item(iBoots, temp != 0);
19436 12 }
19437 116 }
19438
19439
2/2
✓ Branch 0 taken 104 times.
✓ Branch 1 taken 12 times.
116 if(s_version < 10)
19440 {
19441 char tempring, tempsword, tempshield, tempwallet, tempbracelet, tempamulet, tempbow;
19442
19443
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!p_getc(&tempring,f))
19444 {
19445 return qe_invalid;
19446 }
19447
19448
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!p_getc(&tempsword,f))
19449 {
19450 return qe_invalid;
19451 }
19452
19453
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!p_getc(&tempshield,f))
19454 {
19455 return qe_invalid;
19456 }
19457
19458
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!p_getc(&tempwallet,f))
19459 {
19460 return qe_invalid;
19461 }
19462
19463
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!p_getc(&tempbracelet,f))
19464 {
19465 return qe_invalid;
19466 }
19467
19468
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!p_getc(&tempamulet,f))
19469 {
19470 return qe_invalid;
19471 }
19472
19473
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!p_getc(&tempbow,f))
19474 {
19475 return qe_invalid;
19476 }
19477
19478 //old only
19479
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
12 if((Header->zelda_version == 0x192)&&(Header->build<174))
19480 {
19481 tempring=(tempring)?(1<<(tempring-1)):0;
19482 tempsword=(tempsword)?(1<<(tempsword-1)):0;
19483 tempshield=(tempshield)?(1<<(tempshield-1)):0;
19484 tempwallet=(tempwallet)?(1<<(tempwallet-1)):0;
19485 tempbracelet=(tempbracelet)?(1<<(tempbracelet-1)):0;
19486 tempamulet=(tempamulet)?(1<<(tempamulet-1)):0;
19487 tempbow=(tempbow)?(1<<(tempbow-1)):0;
19488 }
19489
19490 //rings start at level 2... wtf
19491 //account for this -DD
19492 12 tempring <<= 1;
19493 12 addOldStyleFamily(&temp_zinit, itemsbuf, itype_ring, tempring);
19494 12 addOldStyleFamily(&temp_zinit, itemsbuf, itype_sword, tempsword);
19495 12 addOldStyleFamily(&temp_zinit, itemsbuf, itype_shield, tempshield);
19496 12 addOldStyleFamily(&temp_zinit, itemsbuf, itype_wallet, tempwallet);
19497 //bracelet ALSO starts at level 2 :-( -DD
19498 12 tempbracelet<<=1;
19499 12 addOldStyleFamily(&temp_zinit, itemsbuf, itype_bracelet, tempbracelet);
19500 12 addOldStyleFamily(&temp_zinit, itemsbuf, itype_amulet, tempamulet);
19501 12 addOldStyleFamily(&temp_zinit, itemsbuf, itype_bow, tempbow);
19502
19503 //new only
19504
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
12 if((Header->zelda_version == 0x192)&&(Header->build>173))
19505 {
19506 for(int32_t q=0; q<32; q++)
19507 {
19508 if(!p_getc(&padding,f))
19509 {
19510 return qe_invalid;
19511 }
19512 }
19513 }
19514
19515 char tempcandle, tempboomerang, temparrow, tempwhistle;
19516
19517
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!p_getc(&tempcandle,f))
19518 {
19519 return qe_invalid;
19520 }
19521
19522
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!p_getc(&tempboomerang,f))
19523 {
19524 return qe_invalid;
19525 }
19526
19527
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!p_getc(&temparrow,f))
19528 {
19529 return qe_invalid;
19530 }
19531
19532
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!p_getc(&temp,f))
19533 {
19534 return qe_invalid;
19535 }
19536
19537 12 addOldStyleFamily(&temp_zinit, itemsbuf, itype_potion, temp);
19538
19539
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!p_getc(&tempwhistle,f))
19540 {
19541 return qe_invalid;
19542 }
19543
19544 //old only
19545
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
12 if((Header->zelda_version == 0x192)&&(Header->build<174))
19546 {
19547 tempcandle=(tempcandle)?(1<<(tempcandle-1)):0;
19548 tempboomerang=(tempboomerang)?(1<<(tempboomerang-1)):0;
19549 temparrow=(temparrow)?(1<<(temparrow-1)):0;
19550 tempwhistle=(tempwhistle)?(1<<(tempwhistle-1)):0;
19551 }
19552
19553 12 addOldStyleFamily(&temp_zinit, itemsbuf, itype_candle, tempcandle);
19554 12 addOldStyleFamily(&temp_zinit, itemsbuf, itype_brang, tempboomerang);
19555 12 addOldStyleFamily(&temp_zinit, itemsbuf, itype_arrow, temparrow);
19556 12 addOldStyleFamily(&temp_zinit, itemsbuf, itype_whistle, tempwhistle);
19557 //What about the potion...?
19558
19559 12 }
19560
19561
2/2
✓ Branch 0 taken 27 times.
✓ Branch 1 taken 89 times.
116 if(s_version < 29)
19562 {
19563 //Oh sure, stick these IN THE MIDDLE OF THE ITEMS, just to make me want
19564 //to jab out my eye...
19565
1/2
✓ Branch 0 taken 89 times.
✗ Branch 1 not taken.
89 if(!p_getc(&padding,f))
19566 return qe_invalid;
19567 89 temp_zinit.counter[crBOMBS] = padding;
19568
19569
1/2
✓ Branch 0 taken 89 times.
✗ Branch 1 not taken.
89 if(!p_getc(&padding,f))
19570 return qe_invalid;
19571 89 temp_zinit.counter[crSBOMBS] = padding;
19572 89 }
19573
19574 //Back to more OLD item code
19575
2/2
✓ Branch 0 taken 104 times.
✓ Branch 1 taken 12 times.
116 if(s_version < 10)
19576 {
19577
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
12 if((Header->zelda_version > 0x192)||
19578 //new only
19579 ((Header->zelda_version == 0x192)&&(Header->build>173)))
19580 {
19581
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!p_getc(&temp,f))
19582 {
19583 return qe_invalid;
19584 }
19585
19586 12 addOldStyleFamily(&temp_zinit, itemsbuf, itype_wand, temp);
19587
19588
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!p_getc(&temp,f))
19589 {
19590 return qe_invalid;
19591 }
19592
19593 12 addOldStyleFamily(&temp_zinit, itemsbuf, itype_letter, temp);
19594
19595
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!p_getc(&temp,f))
19596 {
19597 return qe_invalid;
19598 }
19599
19600 12 addOldStyleFamily(&temp_zinit, itemsbuf, itype_lens, temp);
19601
19602
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!p_getc(&temp,f))
19603 {
19604 return qe_invalid;
19605 }
19606
19607 12 addOldStyleFamily(&temp_zinit, itemsbuf, itype_hookshot, temp);
19608
19609
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!p_getc(&temp,f))
19610 {
19611 return qe_invalid;
19612 }
19613
19614 12 addOldStyleFamily(&temp_zinit, itemsbuf, itype_bait, temp);
19615
19616
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!p_getc(&temp,f))
19617 {
19618 return qe_invalid;
19619 }
19620
19621 12 addOldStyleFamily(&temp_zinit, itemsbuf, itype_hammer, temp);
19622
19623
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!p_getc(&temp,f))
19624 {
19625 return qe_invalid;
19626 }
19627
19628 12 addOldStyleFamily(&temp_zinit, itemsbuf, itype_divinefire, temp);
19629
19630
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!p_getc(&temp,f))
19631 {
19632 return qe_invalid;
19633 }
19634
19635 12 addOldStyleFamily(&temp_zinit, itemsbuf, itype_divineescape, temp);
19636
19637
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!p_getc(&temp,f))
19638 {
19639 return qe_invalid;
19640 }
19641
19642 12 addOldStyleFamily(&temp_zinit, itemsbuf, itype_divineprotection, temp);
19643
19644
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!p_getc(&temp,f))
19645 {
19646 return qe_invalid;
19647 }
19648
19649
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(Header->zelda_version == 0x192)
19650 {
19651 for(int32_t q=0; q<32; q++)
19652 {
19653 if(!p_getc(&padding,f))
19654 {
19655 return qe_invalid;
19656 }
19657 }
19658 }
19659 12 }
19660 12 }
19661
19662 //old only
19663
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 116 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
116 if((Header->zelda_version == 0x192)&&(Header->build<174))
19664 {
19665 byte equipment, tmpitm; //bit flags
19666
19667 if(!p_getc(&equipment,f))
19668 {
19669 return qe_invalid;
19670 }
19671
19672 temp_zinit.set_item(iRaft, get_bit(&equipment, idE_RAFT)!=0);
19673 temp_zinit.set_item(iLadder, get_bit(&equipment, idE_LADDER)!=0);
19674 temp_zinit.set_item(iBook, get_bit(&equipment, idE_BOOK)!=0);
19675 temp_zinit.set_item(iMKey, get_bit(&equipment, idE_KEY)!=0);
19676 temp_zinit.set_item(iFlippers, get_bit(&equipment, idE_FLIPPERS)!=0);
19677 temp_zinit.set_item(iBoots, get_bit(&equipment, idE_BOOTS)!=0);
19678
19679
19680 if(!p_getc(&tmpitm,f))
19681 {
19682 return qe_invalid;
19683 }
19684
19685 temp_zinit.set_item(iWand, get_bit(&tmpitm, idI_WAND)!=0);
19686 temp_zinit.set_item(iLetter, get_bit(&tmpitm, idI_LETTER)!=0);
19687 temp_zinit.set_item(iLens, get_bit(&tmpitm, idI_LENS)!=0);
19688 temp_zinit.set_item(iHookshot, get_bit(&tmpitm, idI_HOOKSHOT)!=0);
19689 temp_zinit.set_item(iBait, get_bit(&tmpitm, idI_BAIT)!=0);
19690 temp_zinit.set_item(iHammer, get_bit(&tmpitm, idI_HAMMER)!=0);
19691 }
19692
19693
1/2
✓ Branch 0 taken 116 times.
✗ Branch 1 not taken.
116 if(!p_getc(&tempbyte,f))
19694 return qe_invalid;
19695 116 temp_zinit.mcounter[crLIFE] = tempbyte;
19696
19697
19698
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 104 times.
116 if(s_version < 14)
19699 {
19700 byte temphp;
19701
19702
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!p_getc(&temphp,f))
19703 {
19704 return qe_invalid;
19705 }
19706
19707 12 temp_zinit.counter[crLIFE]=temphp;
19708
19709
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!p_getc(&temphp,f))
19710 {
19711 return qe_invalid;
19712 }
19713
19714 12 temp_zinit.cont_heart=temphp;
19715 12 }
19716 else
19717 {
19718
1/2
✓ Branch 0 taken 104 times.
✗ Branch 1 not taken.
104 if(!p_igetw(&temp_zinit.counter[crLIFE],f))
19719 {
19720 return qe_invalid;
19721 }
19722
19723
1/2
✓ Branch 0 taken 104 times.
✗ Branch 1 not taken.
104 if(!p_igetw(&temp_zinit.cont_heart,f))
19724 {
19725 return qe_invalid;
19726 }
19727 }
19728
19729
1/2
✓ Branch 0 taken 116 times.
✗ Branch 1 not taken.
116 if(!p_getc(&temp_zinit.hcp,f))
19730 {
19731 return qe_invalid;
19732 }
19733
19734
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 104 times.
116 if(s_version >= 14)
19735 {
19736
1/2
✓ Branch 0 taken 104 times.
✗ Branch 1 not taken.
104 if(!p_getc(&temp_zinit.hcp_per_hc,f))
19737 {
19738 return qe_invalid;
19739 }
19740
19741
1/2
✓ Branch 0 taken 104 times.
✗ Branch 1 not taken.
104 if(s_version<16) // July 2007
19742 {
19743 if(get_qr(qr_BRANGPICKUP+1))
19744 temp_zinit.hcp_per_hc = 0xFF;
19745
19746 //Dispose of legacy rule
19747 set_qr(qr_BRANGPICKUP+1, 0);
19748 }
19749 104 }
19750
19751
2/2
✓ Branch 0 taken 27 times.
✓ Branch 1 taken 89 times.
116 if(s_version < 29)
19752 {
19753
1/2
✓ Branch 0 taken 89 times.
✗ Branch 1 not taken.
89 if(!p_getc(&padding,f))
19754 return qe_invalid;
19755 89 temp_zinit.mcounter[crBOMBS] = padding;
19756 89 }
19757
19758
1/2
✓ Branch 0 taken 116 times.
✗ Branch 1 not taken.
116 if(!p_getc(&temp_zinit.counter[crKEYS],f))
19759 {
19760 return qe_invalid;
19761 }
19762
19763
1/2
✓ Branch 0 taken 116 times.
✗ Branch 1 not taken.
116 if(!p_igetw(&temp_zinit.counter[crMONEY],f))
19764 {
19765 return qe_invalid;
19766 }
19767
19768
1/2
✓ Branch 0 taken 116 times.
✗ Branch 1 not taken.
116 if(!p_getc(&tempbyte,f))
19769 return qe_invalid;
19770
2/2
✓ Branch 0 taken 928 times.
✓ Branch 1 taken 116 times.
1044 for(int q = 0; q < 8; ++q)
19771 928 set_bit(temp_zinit.mcguffin, q+1, get_bitl(tempbyte, q));
19772
19773
3/6
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 104 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 12 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
116 if(s_version>12 || (Header->zelda_version == 0x211 && Header->build == 18))
19774 {
19775
2/2
✓ Branch 0 taken 6656 times.
✓ Branch 1 taken 104 times.
6760 for(int32_t i=0; i<64; i++)
19776 {
19777
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6656 times.
6656 if(!p_getc(&temp_zinit.map[i],f))
19778 {
19779 return qe_invalid;
19780 }
19781 6656 }
19782
19783
2/2
✓ Branch 0 taken 6656 times.
✓ Branch 1 taken 104 times.
6760 for(int32_t i=0; i<64; i++)
19784 {
19785
1/2
✓ Branch 0 taken 6656 times.
✗ Branch 1 not taken.
6656 if(!p_getc(&temp_zinit.compass[i],f))
19786 {
19787 return qe_invalid;
19788 }
19789 6656 }
19790 104 }
19791 else
19792 {
19793
2/2
✓ Branch 0 taken 384 times.
✓ Branch 1 taken 12 times.
396 for(int32_t i=0; i<32; i++)
19794 {
19795
1/2
✓ Branch 0 taken 384 times.
✗ Branch 1 not taken.
384 if(!p_getc(&temp_zinit.map[i],f))
19796 {
19797 return qe_invalid;
19798 }
19799 384 }
19800
19801
2/2
✓ Branch 0 taken 384 times.
✓ Branch 1 taken 12 times.
396 for(int32_t i=0; i<32; i++)
19802 {
19803
1/2
✓ Branch 0 taken 384 times.
✗ Branch 1 not taken.
384 if(!p_getc(&temp_zinit.compass[i],f))
19804 {
19805 return qe_invalid;
19806 }
19807 384 }
19808 }
19809
19810
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 116 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
116 if((Header->zelda_version > 0x192)||
19811 //new only
19812 ((Header->zelda_version == 0x192)&&(Header->build>173)))
19813 {
19814
3/6
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 104 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 12 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
116 if(s_version>12 || (Header->zelda_version == 0x211 && Header->build == 18))
19815 {
19816
2/2
✓ Branch 0 taken 6656 times.
✓ Branch 1 taken 104 times.
6760 for(int32_t i=0; i<64; i++)
19817 {
19818
1/2
✓ Branch 0 taken 6656 times.
✗ Branch 1 not taken.
6656 if(!p_getc(&temp_zinit.boss_key[i],f))
19819 {
19820 return qe_invalid;
19821 }
19822 6656 }
19823 104 }
19824 else
19825 {
19826
2/2
✓ Branch 0 taken 384 times.
✓ Branch 1 taken 12 times.
396 for(int32_t i=0; i<32; i++)
19827 {
19828
1/2
✓ Branch 0 taken 384 times.
✗ Branch 1 not taken.
384 if(!p_getc(&temp_zinit.boss_key[i],f))
19829 {
19830 return qe_invalid;
19831 }
19832 384 }
19833 }
19834 116 }
19835
19836 byte tmpmisc[16];
19837
2/2
✓ Branch 0 taken 1856 times.
✓ Branch 1 taken 116 times.
1972 for(int32_t i=0; i<16; i++)
19838
1/2
✓ Branch 0 taken 1856 times.
✗ Branch 1 not taken.
1856 if(!p_getc(&tmpmisc[i],f))
19839 return qe_invalid;
19840 116 temp_zinit.flags.set(INIT_FL_CONTPERCENT,get_bit(tmpmisc,0));
19841 116 temp_zinit.magicdrainrate = get_bit(tmpmisc,1) ? 1 : 2; //Double Magic flag
19842 116 temp_zinit.flags.set(INIT_FL_CANSLASH,get_bit(tmpmisc,2));
19843
19844
4/4
✓ Branch 0 taken 104 times.
✓ Branch 1 taken 12 times.
✓ Branch 2 taken 48 times.
✓ Branch 3 taken 12 times.
164 if(s_version < 15) for(int32_t i=0; i<4; i++)
19845
1/2
✓ Branch 0 taken 48 times.
✗ Branch 1 not taken.
48 if(!p_getc(&sword_hearts[i],f))
19846 12 return qe_invalid;
19847
19848
1/2
✓ Branch 0 taken 116 times.
✗ Branch 1 not taken.
116 if(!p_getc(&temp_zinit.last_map,f))
19849 {
19850 return qe_invalid;
19851 }
19852
19853
1/2
✓ Branch 0 taken 116 times.
✗ Branch 1 not taken.
116 if(!p_getc(&temp_zinit.last_screen,f))
19854 {
19855 return qe_invalid;
19856 }
19857
19858
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 104 times.
116 if(s_version < 14)
19859 {
19860 byte tempmp;
19861
19862
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!p_getc(&tempmp,f))
19863 {
19864 return qe_invalid;
19865 }
19866
19867 12 temp_zinit.mcounter[crMAGIC]=tempmp;
19868
19869
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!p_getc(&tempmp,f))
19870 {
19871 return qe_invalid;
19872 }
19873
19874 12 temp_zinit.counter[crMAGIC]=tempmp;
19875 12 }
19876 else
19877 {
19878
1/2
✓ Branch 0 taken 104 times.
✗ Branch 1 not taken.
104 if(!p_igetw(&temp_zinit.mcounter[crMAGIC],f))
19879 {
19880 return qe_invalid;
19881 }
19882
19883
1/2
✓ Branch 0 taken 104 times.
✗ Branch 1 not taken.
104 if(!p_igetw(&temp_zinit.counter[crMAGIC],f))
19884 {
19885 return qe_invalid;
19886 }
19887 }
19888
19889
19890
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 104 times.
116 if(s_version < 15)
19891 {
19892
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if(s_version < 12)
19893 {
19894 12 temp_zinit.mcounter[crMAGIC]*=32;
19895 12 temp_zinit.counter[crMAGIC]*=32;
19896 12 }
19897
19898
2/2
✓ Branch 0 taken 48 times.
✓ Branch 1 taken 12 times.
60 for(int32_t i=0; i<4; i++)
19899 {
19900
1/2
✓ Branch 0 taken 48 times.
✗ Branch 1 not taken.
48 if(!p_getc(&beam_hearts[i],f))
19901 {
19902 return qe_invalid;
19903 }
19904 48 }
19905
19906
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!p_getc(&beam_percent,f))
19907 {
19908 return qe_invalid;
19909 }
19910 12 }
19911 else
19912 {
19913
1/2
✓ Branch 0 taken 104 times.
✗ Branch 1 not taken.
104 if(!p_getc(&temp_zinit.bomb_ratio,f))
19914 return qe_invalid;
19915
1/2
✓ Branch 0 taken 104 times.
✗ Branch 1 not taken.
104 if(temp_zinit.bomb_ratio < 1)
19916 temp_zinit.bomb_ratio = 1;
19917 104 else bomb_ratio = temp_zinit.bomb_ratio; //jank
19918 }
19919
19920
2/2
✓ Branch 0 taken 104 times.
✓ Branch 1 taken 12 times.
116 if(s_version < 15)
19921 {
19922 byte tempbp;
19923
19924
2/2
✓ Branch 0 taken 48 times.
✓ Branch 1 taken 12 times.
60 for(int32_t i=0; i<4; i++)
19925 {
19926
2/4
✓ Branch 0 taken 48 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 48 times.
✗ Branch 3 not taken.
48 if(!(s_version < 14 ? p_getc(&tempbp,f) : p_igetw(&tempbp,f)))
19927 {
19928 return qe_invalid;
19929 }
19930
19931 48 beam_power[i]=tempbp;
19932 48 }
19933
19934
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!p_getc(&hookshot_links,f))
19935 {
19936 return qe_invalid;
19937 }
19938
19939
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(s_version>6)
19940 {
19941 if(!p_getc(&hookshot_length,f))
19942 {
19943 return qe_invalid;
19944 }
19945
19946 if(!p_getc(&longshot_links,f))
19947 {
19948 return qe_invalid;
19949 }
19950
19951 if(!p_getc(&longshot_length,f))
19952 {
19953 return qe_invalid;
19954 }
19955 }
19956 12 }
19957
19958
1/2
✓ Branch 0 taken 116 times.
✗ Branch 1 not taken.
116 if(!p_getc(&temp_zinit.msg_more_x,f))
19959 {
19960 return qe_invalid;
19961 }
19962
19963
1/2
✓ Branch 0 taken 116 times.
✗ Branch 1 not taken.
116 if(!p_getc(&temp_zinit.msg_more_y,f))
19964 {
19965 return qe_invalid;
19966 }
19967
19968
1/2
✓ Branch 0 taken 116 times.
✗ Branch 1 not taken.
116 if(!p_getc(&subscr_mode,f))
19969 return qe_invalid;
19970
19971 //old only
19972
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 116 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
116 if((Header->zelda_version == 0x192)&&(Header->build<174))
19973 {
19974 for(int32_t i=0; i<32; i++)
19975 {
19976 if(!p_getc(&temp_zinit.boss_key[i],f))
19977 {
19978 return qe_invalid;
19979 }
19980 }
19981 }
19982
19983
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 116 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
116 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>173))) //new only
19984 {
19985
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 104 times.
116 if(s_version <= 10)
19986 {
19987
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!p_getc(&tempbyte,f))
19988 {
19989 return qe_invalid;
19990 }
19991
19992 12 temp_zinit.start_dmap = (word)tempbyte;
19993 12 }
19994 else
19995 {
19996
1/2
✓ Branch 0 taken 104 times.
✗ Branch 1 not taken.
104 if(!p_igetw(&temp_zinit.start_dmap,f))
19997 {
19998 return qe_invalid;
19999 }
20000 }
20001
20002
1/2
✓ Branch 0 taken 116 times.
✗ Branch 1 not taken.
116 if(!p_getc(&temp_zinit.heroAnimationStyle,f))
20003 {
20004 return qe_invalid;
20005 }
20006 116 }
20007
20008
4/4
✓ Branch 0 taken 104 times.
✓ Branch 1 taken 12 times.
✓ Branch 2 taken 27 times.
✓ Branch 3 taken 77 times.
116 if(s_version>1 && s_version < 29)
20009 {
20010
1/2
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
77 if(!p_getc(&padding,f))
20011 return qe_invalid;
20012 77 temp_zinit.counter[crARROWS] = padding;
20013
20014
1/2
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
77 if(!p_getc(&padding,f))
20015 return qe_invalid;
20016 77 temp_zinit.mcounter[crARROWS] = padding;
20017 77 }
20018
20019
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 104 times.
116 if(s_version>2)
20020 {
20021
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 104 times.
104 if(s_version <= 10)
20022 {
20023 for(int32_t i=0; i<OLDMAXLEVELS; i++)
20024 {
20025 if(!p_getc(&(temp_zinit.level_keys[i]),f))
20026 {
20027 return qe_invalid;
20028 }
20029 }
20030 }
20031 else
20032 {
20033
2/2
✓ Branch 0 taken 53248 times.
✓ Branch 1 taken 104 times.
53352 for(int32_t i=0; i<MAXLEVELS; i++)
20034 {
20035
1/2
✓ Branch 0 taken 53248 times.
✗ Branch 1 not taken.
53248 if(!p_getc(&(temp_zinit.level_keys[i]),f))
20036 {
20037 return qe_invalid;
20038 }
20039 53248 }
20040 }
20041 104 }
20042
20043
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 104 times.
116 if(s_version>3)
20044 {
20045
1/2
✓ Branch 0 taken 104 times.
✗ Branch 1 not taken.
104 if(!p_igetw(&temp_zinit.ss_grid_x,f))
20046 {
20047 return qe_invalid;
20048 }
20049
20050
1/2
✓ Branch 0 taken 104 times.
✗ Branch 1 not taken.
104 if(!p_igetw(&temp_zinit.ss_grid_y,f))
20051 {
20052 return qe_invalid;
20053 }
20054
20055
1/2
✓ Branch 0 taken 104 times.
✗ Branch 1 not taken.
104 if(!p_igetw(&temp_zinit.ss_grid_xofs,f))
20056 {
20057 return qe_invalid;
20058 }
20059
20060
1/2
✓ Branch 0 taken 104 times.
✗ Branch 1 not taken.
104 if(!p_igetw(&temp_zinit.ss_grid_yofs,f))
20061 {
20062 return qe_invalid;
20063 }
20064
20065
1/2
✓ Branch 0 taken 104 times.
✗ Branch 1 not taken.
104 if(!p_igetw(&temp_zinit.ss_grid_color,f))
20066 {
20067 return qe_invalid;
20068 }
20069
20070
1/2
✓ Branch 0 taken 104 times.
✗ Branch 1 not taken.
104 if(!p_igetw(&temp_zinit.ss_bbox_1_color,f))
20071 {
20072 return qe_invalid;
20073 }
20074
20075
1/2
✓ Branch 0 taken 104 times.
✗ Branch 1 not taken.
104 if(!p_igetw(&temp_zinit.ss_bbox_2_color,f))
20076 {
20077 return qe_invalid;
20078 }
20079
20080
1/2
✓ Branch 0 taken 104 times.
✗ Branch 1 not taken.
104 if(!p_igetw(&temp_zinit.ss_flags,f))
20081 {
20082 return qe_invalid;
20083 }
20084
20085
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 104 times.
104 temp_zinit.ss_grid_x=zc_max(temp_zinit.ss_grid_x,1);
20086
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 104 times.
104 temp_zinit.ss_grid_y=zc_max(temp_zinit.ss_grid_y,1);
20087 104 }
20088
20089
3/4
✓ Branch 0 taken 104 times.
✓ Branch 1 taken 12 times.
✓ Branch 2 taken 104 times.
✗ Branch 3 not taken.
116 if(s_version>4 && s_version<15)
20090 {
20091 if(!p_getc(&moving_fairy_hearts,f))
20092 {
20093 return qe_invalid;
20094 }
20095
20096 if(!p_getc(&moving_fairy_heart_percent,f))
20097 {
20098 return qe_invalid;
20099 }
20100 }
20101
20102
3/4
✓ Branch 0 taken 104 times.
✓ Branch 1 taken 12 times.
✓ Branch 2 taken 104 times.
✗ Branch 3 not taken.
116 if(s_version>5 && s_version < 10)
20103 {
20104 if(!p_getc(&temp,f))
20105 {
20106 return qe_invalid;
20107 }
20108
20109 addOldStyleFamily(&temp_zinit, itemsbuf, itype_quiver, temp);
20110 }
20111
20112
3/4
✓ Branch 0 taken 104 times.
✓ Branch 1 taken 12 times.
✓ Branch 2 taken 104 times.
✗ Branch 3 not taken.
116 if(s_version>6 && s_version<15)
20113 {
20114 if(!p_getc(&stationary_fairy_hearts,f))
20115 {
20116 return qe_invalid;
20117 }
20118
20119 if(!p_getc(&stationary_fairy_heart_percent,f))
20120 {
20121 return qe_invalid;
20122 }
20123
20124 if(!p_getc(&moving_fairy_magic,f))
20125 {
20126 return qe_invalid;
20127 }
20128
20129 if(!p_getc(&moving_fairy_magic_percent,f))
20130 {
20131 return qe_invalid;
20132 }
20133
20134 if(!p_getc(&stationary_fairy_magic,f))
20135 {
20136 return qe_invalid;
20137 }
20138
20139 if(!p_getc(&stationary_fairy_magic_percent,f))
20140 {
20141 return qe_invalid;
20142 }
20143
20144 if(!p_getc(&blue_potion_hearts,f))
20145 {
20146 return qe_invalid;
20147 }
20148
20149 if(!p_getc(&blue_potion_heart_percent,f))
20150 {
20151 return qe_invalid;
20152 }
20153
20154 if(!p_getc(&red_potion_hearts,f))
20155 {
20156 return qe_invalid;
20157 }
20158
20159 if(!p_getc(&red_potion_heart_percent,f))
20160 {
20161 return qe_invalid;
20162 }
20163
20164 if(!p_getc(&blue_potion_magic,f))
20165 {
20166 return qe_invalid;
20167 }
20168
20169 if(!p_getc(&blue_potion_magic_percent,f))
20170 {
20171 return qe_invalid;
20172 }
20173
20174 if(!p_getc(&red_potion_magic,f))
20175 {
20176 return qe_invalid;
20177 }
20178
20179 if(!p_getc(&red_potion_magic_percent,f))
20180 {
20181 return qe_invalid;
20182 }
20183 }
20184
20185
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 104 times.
116 if(s_version>6)
20186
1/2
✓ Branch 0 taken 104 times.
✗ Branch 1 not taken.
104 if(!p_getc(&padding,f))
20187 return qe_invalid;
20188
20189
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 104 times.
116 if(s_version>7)
20190 {
20191
1/2
✓ Branch 0 taken 104 times.
✗ Branch 1 not taken.
104 if(!p_getc(&padding,f))
20192 {
20193 return qe_invalid;
20194 }
20195 104 }
20196
20197
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 104 times.
116 if(s_version>8)
20198 {
20199
1/2
✓ Branch 0 taken 104 times.
✗ Branch 1 not taken.
104 if(!p_igetw(&temp_zinit.mcounter[crMONEY],f))
20200 {
20201 return qe_invalid;
20202 }
20203
20204
1/2
✓ Branch 0 taken 104 times.
✗ Branch 1 not taken.
104 if(!p_igetw(&temp_zinit.mcounter[crKEYS],f))
20205 {
20206 return qe_invalid;
20207 }
20208 104 }
20209
20210
2/2
✓ Branch 0 taken 104 times.
✓ Branch 1 taken 12 times.
116 if(s_version>16)
20211 {
20212
1/2
✓ Branch 0 taken 104 times.
✗ Branch 1 not taken.
104 if(!p_getc(&tempbyte,f))
20213 {
20214 return qe_invalid;
20215 }
20216 104 temp_zinit.gravity = tempbyte*100;
20217
1/2
✓ Branch 0 taken 104 times.
✗ Branch 1 not taken.
104 if(!p_igetw(&temp_zinit.terminalv,f))
20218 {
20219 return qe_invalid;
20220 }
20221
20222
1/2
✓ Branch 0 taken 104 times.
✗ Branch 1 not taken.
104 if(!p_getc(&temp_zinit.msg_speed,f))
20223 {
20224 return qe_invalid;
20225 }
20226
20227
1/2
✓ Branch 0 taken 104 times.
✗ Branch 1 not taken.
104 if(!p_getc(&padding,f))
20228 {
20229 return qe_invalid;
20230 }
20231
20232
1/2
✓ Branch 0 taken 104 times.
✗ Branch 1 not taken.
104 if(!p_getc(&temp_zinit.jump_hero_layer_threshold,f))
20233 {
20234 return qe_invalid;
20235 }
20236 104 }
20237
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 else if (replay_version_check(0, 13))
20238 12 temp_zinit.msg_speed = 0;
20239
20240
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 104 times.
116 if(s_version>17)
20241 {
20242
1/2
✓ Branch 0 taken 104 times.
✗ Branch 1 not taken.
104 if(!p_getc(&temp_zinit.msg_more_is_offset,f))
20243 {
20244 return qe_invalid;
20245 }
20246 104 }
20247
20248 //expaned init data for larger values in 2.55
20249
2/2
✓ Branch 0 taken 89 times.
✓ Branch 1 taken 27 times.
116 if ( s_version >= 19 ) //expand init data bombs, sbombs, and arrows to 0xFFFF
20250 {
20251
1/2
✓ Branch 0 taken 27 times.
✗ Branch 1 not taken.
27 if(!p_igetw(&temp_zinit.counter[crBOMBS],f))
20252 {
20253 return qe_invalid;
20254 }
20255
1/2
✓ Branch 0 taken 27 times.
✗ Branch 1 not taken.
27 if(!p_igetw(&temp_zinit.counter[crSBOMBS],f))
20256 {
20257 return qe_invalid;
20258 }
20259
1/2
✓ Branch 0 taken 27 times.
✗ Branch 1 not taken.
27 if(!p_igetw(&temp_zinit.mcounter[crBOMBS],f))
20260 {
20261 return qe_invalid;
20262 }
20263
1/2
✓ Branch 0 taken 27 times.
✗ Branch 1 not taken.
27 if(!p_igetw(&temp_zinit.mcounter[crSBOMBS],f))
20264 {
20265 return qe_invalid;
20266 }
20267
1/2
✓ Branch 0 taken 27 times.
✗ Branch 1 not taken.
27 if(!p_igetw(&temp_zinit.counter[crARROWS],f))
20268 {
20269 return qe_invalid;
20270 }
20271
1/2
✓ Branch 0 taken 27 times.
✗ Branch 1 not taken.
27 if(!p_igetw(&temp_zinit.mcounter[crARROWS],f))
20272 {
20273 return qe_invalid;
20274 }
20275
20276 27 }
20277
2/2
✓ Branch 0 taken 27 times.
✓ Branch 1 taken 89 times.
116 if ( s_version >= 20 )
20278 {
20279
1/2
✓ Branch 0 taken 27 times.
✗ Branch 1 not taken.
27 if(!p_igetw(&temp_zinit.heroStep,f))
20280 {
20281 return qe_invalid;
20282 }
20283 27 }
20284 else
20285 {
20286 89 temp_zinit.heroStep = 150; //1.5 pixels per frame
20287 }
20288
2/2
✓ Branch 0 taken 27 times.
✓ Branch 1 taken 89 times.
116 if ( s_version >= 21 )
20289 {
20290
1/2
✓ Branch 0 taken 27 times.
✗ Branch 1 not taken.
27 if(!p_igetw(&temp_zinit.subscrSpeed,f))
20291 {
20292 return qe_invalid;
20293 }
20294 27 }
20295 else
20296 {
20297 89 temp_zinit.subscrSpeed = 1; //3 pixels per frame
20298 }
20299 //old only
20300
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 116 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
116 if((Header->zelda_version == 0x192)&&(Header->build<174))
20301 {
20302 byte items2;
20303
20304 if(!p_getc(&items2,f))
20305 {
20306 return qe_invalid;
20307 }
20308
20309 temp_zinit.set_item(iDivineFire, get_bit(&items2, idI_DFIRE)!=0);
20310 temp_zinit.set_item(iDivineEscape, get_bit(&items2, idI_FWIND)!=0);
20311 temp_zinit.set_item(iDivineProtection, get_bit(&items2, idI_NLOVE)!=0);
20312 }
20313
20314
1/2
✓ Branch 0 taken 116 times.
✗ Branch 1 not taken.
116 if(Header->zelda_version < 0x193)
20315 {
20316 for(int32_t q=0; q<96; q++)
20317 {
20318 if(!p_getc(&padding,f))
20319 {
20320 return qe_invalid;
20321 }
20322 }
20323
20324 //new only
20325 if((Header->zelda_version == 0x192)&&(Header->build>173))
20326 {
20327 if(!p_getc(&padding,f))
20328 {
20329 return qe_invalid;
20330 }
20331
20332 if(!p_getc(&padding,f))
20333 {
20334 return qe_invalid;
20335 }
20336 }
20337 }
20338 116 }
20339
20340
3/6
✓ Branch 0 taken 104 times.
✓ Branch 1 taken 16 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 104 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
120 if((Header->zelda_version < 0x211)||((Header->zelda_version == 0x211)&&(Header->build<15)))
20341 {
20342 //temp_zinit.shield=i_smallshield;
20343 16 int32_t sshieldid = getItemID(itemsbuf, itype_shield, i_smallshield);
20344
20345
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(sshieldid != -1)
20346 16 temp_zinit.set_item(sshieldid, true);
20347 16 }
20348
20349
3/6
✓ Branch 0 taken 116 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 116 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
120 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<27)))
20350 {
20351 4 temp_zinit.mcounter[crLIFE]=3;
20352 4 temp_zinit.counter[crLIFE]=3;
20353 4 temp_zinit.cont_heart=3;
20354 4 temp_zinit.mcounter[crBOMBS]=8;
20355 4 }
20356
20357
3/6
✓ Branch 0 taken 116 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 116 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
120 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<50)))
20358 {
20359 4 sword_hearts[0]=0;
20360 4 sword_hearts[1]=5;
20361 4 sword_hearts[2]=12;
20362 4 sword_hearts[3]=21;
20363 4 }
20364
20365
3/6
✓ Branch 0 taken 116 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 116 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
120 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<51)))
20366 {
20367 4 temp_zinit.last_map=0;
20368 4 temp_zinit.last_screen=0;
20369 4 }
20370
20371
3/6
✓ Branch 0 taken 116 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 116 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
120 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<68)))
20372 {
20373 4 temp_zinit.mcounter[crMAGIC]=0;
20374 4 temp_zinit.counter[crMAGIC]=0;
20375 4 temp_zinit.magicdrainrate = 2;
20376 4 }
20377
20378
3/6
✓ Branch 0 taken 116 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 116 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
120 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<129)))
20379 {
20380
20381
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 4 times.
20 for(int32_t x=0; x<4; x++)
20382 {
20383 16 beam_hearts[x]=100;
20384 16 }
20385
20386
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 4 times.
20 for(int32_t i=0; i<idBP_MAX; i++)
20387 {
20388 16 set_bit(&beam_percent,i,!get_qr(qr_LENSHINTS+i));
20389 16 set_qr(qr_LENSHINTS+i,0);
20390 16 }
20391
20392
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 4 times.
20 for(int32_t x=0; x<4; x++)
20393 {
20394 16 beam_power[x]=get_qr(qr_HIDECARRIEDITEMS)?50:100;
20395 16 }
20396
20397 4 set_qr(qr_HIDECARRIEDITEMS,0);
20398 4 hookshot_links=100;
20399 4 temp_zinit.msg_more_x=224;
20400 4 temp_zinit.msg_more_y=64;
20401 4 }
20402
20403 // Okay, let's put these legacy values into itemsbuf.
20404
2/2
✓ Branch 0 taken 104 times.
✓ Branch 1 taken 16 times.
120 if(s_version < 15)
20405
2/2
✓ Branch 0 taken 4096 times.
✓ Branch 1 taken 16 times.
4112 for(int32_t i=0; i<MAXITEMS; i++)
20406 {
20407
11/11
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 16 times.
✓ Branch 2 taken 16 times.
✓ Branch 3 taken 16 times.
✓ Branch 4 taken 16 times.
✓ Branch 5 taken 16 times.
✓ Branch 6 taken 16 times.
✓ Branch 7 taken 16 times.
✓ Branch 8 taken 3936 times.
✓ Branch 9 taken 16 times.
✓ Branch 10 taken 16 times.
4096 switch(i)
20408 {
20409 case iFairyStill:
20410 16 itemsbuf[i].misc1 = stationary_fairy_hearts;
20411 16 itemsbuf[i].misc2 = stationary_fairy_magic;
20412 16 itemsbuf[i].misc3 = 0;
20413 16 itemsbuf[i].flags |= stationary_fairy_heart_percent ? ITEM_FLAG1 : 0;
20414 16 itemsbuf[i].flags |= stationary_fairy_magic_percent ? ITEM_FLAG2 : 0;
20415 16 break;
20416
20417 case iFairyMoving:
20418 16 itemsbuf[i].misc1 = moving_fairy_hearts;
20419 16 itemsbuf[i].misc2 = moving_fairy_magic;
20420 16 itemsbuf[i].misc3 = 50;
20421 16 itemsbuf[i].flags |= moving_fairy_heart_percent ? ITEM_FLAG1 : 0;
20422 16 itemsbuf[i].flags |= moving_fairy_magic_percent ? ITEM_FLAG2 : 0;
20423 16 break;
20424
20425 case iRPotion:
20426 16 itemsbuf[i].misc1 = red_potion_hearts;
20427 16 itemsbuf[i].misc2 = red_potion_magic;
20428 16 itemsbuf[i].flags |= red_potion_heart_percent ? ITEM_FLAG1 : 0;
20429 16 itemsbuf[i].flags |= red_potion_magic_percent ? ITEM_FLAG2 : 0;
20430 16 break;
20431
20432 case iBPotion:
20433 16 itemsbuf[i].misc1 = blue_potion_hearts;
20434 16 itemsbuf[i].misc2 = blue_potion_magic;
20435 16 itemsbuf[i].flags |= blue_potion_heart_percent ? ITEM_FLAG1 : 0;
20436 16 itemsbuf[i].flags |= blue_potion_magic_percent ? ITEM_FLAG2 : 0;
20437 16 break;
20438
20439 case iSword:
20440 16 itemsbuf[i].pickup_hearts = sword_hearts[0];
20441 16 itemsbuf[i].misc1 = beam_hearts[0];
20442 16 itemsbuf[i].misc2 = beam_power[0];
20443 // It seems that ITEM_FLAG1 was already added by reset_itembuf()...
20444 16 itemsbuf[i].flags &= (!get_bit(&beam_percent,0)) ? ~ITEM_FLAG1 : ~0;
20445 16 break;
20446
20447 case iWSword:
20448 16 itemsbuf[i].pickup_hearts = sword_hearts[1];
20449 16 itemsbuf[i].misc1 = beam_hearts[1];
20450 16 itemsbuf[i].misc2 = beam_power[1];
20451 16 itemsbuf[i].flags &= (!get_bit(&beam_percent,1)) ? ~ITEM_FLAG1 : ~0;
20452 16 break;
20453
20454 case iMSword:
20455 16 itemsbuf[i].pickup_hearts = sword_hearts[2];
20456 16 itemsbuf[i].misc1 = beam_hearts[2];
20457 16 itemsbuf[i].misc2 = beam_power[2];
20458 16 itemsbuf[i].flags &= (!get_bit(&beam_percent,2)) ? ~ITEM_FLAG1 : ~0;
20459 16 break;
20460
20461 case iXSword:
20462 16 itemsbuf[i].pickup_hearts = sword_hearts[3];
20463 16 itemsbuf[i].misc1 = beam_hearts[3];
20464 16 itemsbuf[i].misc2 = beam_power[3];
20465 16 itemsbuf[i].flags &= (!get_bit(&beam_percent,3)) ? ~ITEM_FLAG1 : ~0;
20466 16 break;
20467
20468 case iHookshot:
20469 16 itemsbuf[i].misc1 = hookshot_length;
20470 16 itemsbuf[i].misc2 = hookshot_links;
20471 16 break;
20472
20473 case iLongshot:
20474 16 itemsbuf[i].misc1 = longshot_length;
20475 16 itemsbuf[i].misc2 = longshot_links;
20476 16 break;
20477 }
20478 4112 }
20479
20480
3/6
✓ Branch 0 taken 116 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 116 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
120 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<168)))
20481 {
20482 //was new subscreen rule
20483 4 subscr_mode=get_qr(qr_FREEFORM)?1:0;
20484 4 set_qr(qr_FREEFORM,0);
20485 4 }
20486
20487
3/6
✓ Branch 0 taken 116 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 116 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
120 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<185)))
20488 {
20489 4 temp_zinit.start_dmap=0;
20490 4 }
20491
20492
3/6
✓ Branch 0 taken 116 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 116 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
120 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<186)))
20493 {
20494 4 temp_zinit.heroAnimationStyle=get_qr(qr_BSZELDA)?1:0;
20495 4 }
20496
20497
3/4
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 104 times.
✓ Branch 2 taken 16 times.
✗ Branch 3 not taken.
120 if(s_version < 16 && get_bit(deprecated_rules, qr_COOLSCROLL+1))
20498 {
20499 //addOldStyleFamily(&temp_zinit, itemsbuf, itype_wallet, 4); //is this needed?
20500 temp_zinit.mcounter[crMONEY]=999;
20501 //temp_zinit.counter[crMONEY]=999; //This rule only gave you an invisible max wallet; it did not give you max rupies.
20502 }
20503
1/2
✓ Branch 0 taken 120 times.
✗ Branch 1 not taken.
120 if(Header->zelda_version < 0x190) //1.84 bugfix. -Z
20504 {
20505 //temp_zinit.items[iBombBag] = true; //No, this is 30 max bombs!
20506 temp_zinit.mcounter[crBOMBS] = 8;
20507 }
20508 // al_trace("About to copy over new init data values for quest made in: %x\n", Header->zelda_version);
20509 //time to ensure that we port all new values properly:
20510
2/2
✓ Branch 0 taken 104 times.
✓ Branch 1 taken 16 times.
120 if(Header->zelda_version < 0x250)
20511 {
20512
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 temp_zinit.mcounter[crSBOMBS] = bomb_ratio > 0 ? ( temp_zinit.mcounter[crBOMBS]/temp_zinit.bomb_ratio ) : (temp_zinit.mcounter[crBOMBS]/4);
20513 16 }
20514
20515
2/2
✓ Branch 0 taken 27 times.
✓ Branch 1 taken 93 times.
120 if(s_version > 21)
20516 {
20517
1/2
✓ Branch 0 taken 27 times.
✗ Branch 1 not taken.
27 if(!p_getc(&temp_zinit.hp_per_heart,f))
20518 {
20519 return qe_invalid;
20520 }
20521
1/2
✓ Branch 0 taken 27 times.
✗ Branch 1 not taken.
27 if(!p_getc(&temp_zinit.magic_per_block,f))
20522 {
20523 return qe_invalid;
20524 }
20525
1/2
✓ Branch 0 taken 27 times.
✗ Branch 1 not taken.
27 if(!p_getc(&temp_zinit.hero_damage_multiplier,f))
20526 {
20527 return qe_invalid;
20528 }
20529
1/2
✓ Branch 0 taken 27 times.
✗ Branch 1 not taken.
27 if(!p_getc(&temp_zinit.ene_damage_multiplier,f))
20530 {
20531 return qe_invalid;
20532 }
20533 27 }
20534 else
20535 {
20536 93 temp_zinit.hp_per_heart = 16; //HP_PER_HEART, previously hardcoded
20537 93 temp_zinit.magic_per_block = 32; //MAGICPERBLOCK, previously hardcoded
20538 93 temp_zinit.hero_damage_multiplier = 2; //DAMAGE_MULTIPLIER, previously hardcoded
20539 93 temp_zinit.ene_damage_multiplier = 4; //(HP_PER_HEART/4), previously hardcoded
20540 }
20541
20542
2/2
✓ Branch 0 taken 93 times.
✓ Branch 1 taken 27 times.
120 if(s_version > 22)
20543 {
20544
2/2
✓ Branch 0 taken 675 times.
✓ Branch 1 taken 27 times.
702 for(int32_t q = crCUSTOM1; q <= crCUSTOM25; ++q)
20545
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 675 times.
675 if(!p_igetw(&temp_zinit.counter[q],f))
20546 return qe_invalid;
20547
2/2
✓ Branch 0 taken 675 times.
✓ Branch 1 taken 27 times.
702 for(int32_t q = crCUSTOM1; q <= crCUSTOM25; ++q)
20548
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 675 times.
675 if(!p_igetw(&temp_zinit.mcounter[q],f))
20549 return qe_invalid;
20550 27 }
20551
20552
20553
2/2
✓ Branch 0 taken 27 times.
✓ Branch 1 taken 93 times.
120 if(s_version > 23)
20554 {
20555
1/2
✓ Branch 0 taken 27 times.
✗ Branch 1 not taken.
27 if(!p_getc(&temp_zinit.dither_type,f))
20556 {
20557 return qe_invalid;
20558 }
20559
1/2
✓ Branch 0 taken 27 times.
✗ Branch 1 not taken.
27 if(!p_getc(&temp_zinit.dither_arg,f))
20560 {
20561 return qe_invalid;
20562 }
20563
1/2
✓ Branch 0 taken 27 times.
✗ Branch 1 not taken.
27 if(!p_getc(&temp_zinit.dither_percent,f))
20564 {
20565 return qe_invalid;
20566 }
20567
1/2
✓ Branch 0 taken 27 times.
✗ Branch 1 not taken.
27 if(!p_getc(&temp_zinit.def_lightrad,f))
20568 {
20569 return qe_invalid;
20570 }
20571
1/2
✓ Branch 0 taken 27 times.
✗ Branch 1 not taken.
27 if(!p_getc(&temp_zinit.transdark_percent,f))
20572 {
20573 return qe_invalid;
20574 }
20575 27 }
20576 else
20577 {
20578 93 temp_zinit.dither_type = 0;
20579 93 temp_zinit.dither_arg = 0;
20580 93 temp_zinit.dither_percent = 20;
20581 93 temp_zinit.def_lightrad = 24;
20582 93 temp_zinit.transdark_percent = 0;
20583 }
20584
20585
2/2
✓ Branch 0 taken 27 times.
✓ Branch 1 taken 93 times.
120 if(s_version > 24)
20586 {
20587
1/2
✓ Branch 0 taken 27 times.
✗ Branch 1 not taken.
27 if(!p_getc(&temp_zinit.darkcol,f))
20588 {
20589 return qe_invalid;
20590 }
20591 27 }
20592 else
20593 {
20594 93 temp_zinit.darkcol = BLACK;
20595 }
20596
20597
2/2
✓ Branch 0 taken 93 times.
✓ Branch 1 taken 27 times.
120 if(s_version > 25)
20598 {
20599
1/2
✓ Branch 0 taken 27 times.
✗ Branch 1 not taken.
27 if(!p_igetl(&temp_zinit.gravity,f))
20600 {
20601 return qe_invalid;
20602 }
20603
1/2
✓ Branch 0 taken 27 times.
✗ Branch 1 not taken.
27 if(!p_igetl(&temp_zinit.swimgravity,f))
20604 {
20605 return qe_invalid;
20606 }
20607 27 }
20608
20609
20610
2/2
✓ Branch 0 taken 27 times.
✓ Branch 1 taken 93 times.
120 if(s_version > 26)
20611 {
20612
1/2
✓ Branch 0 taken 27 times.
✗ Branch 1 not taken.
27 if(!p_igetw(&temp_zinit.heroSideswimUpStep,f))
20613 {
20614 return qe_invalid;
20615 }
20616
1/2
✓ Branch 0 taken 27 times.
✗ Branch 1 not taken.
27 if(!p_igetw(&temp_zinit.heroSideswimSideStep,f))
20617 {
20618 return qe_invalid;
20619 }
20620
1/2
✓ Branch 0 taken 27 times.
✗ Branch 1 not taken.
27 if(!p_igetw(&temp_zinit.heroSideswimDownStep,f))
20621 {
20622 return qe_invalid;
20623 }
20624 27 }
20625 else
20626 {
20627 93 temp_zinit.heroSideswimUpStep = 150;
20628 93 temp_zinit.heroSideswimSideStep = 100;
20629 93 temp_zinit.heroSideswimDownStep = 75;
20630 }
20631
20632
2/2
✓ Branch 0 taken 27 times.
✓ Branch 1 taken 93 times.
120 if(s_version > 27)
20633 {
20634
1/2
✓ Branch 0 taken 27 times.
✗ Branch 1 not taken.
27 if(!p_igetl(&temp_zinit.exitWaterJump,f))
20635 {
20636 return qe_invalid;
20637 }
20638 27 }
20639 else
20640 {
20641 93 temp_zinit.exitWaterJump = 0;
20642 }
20643
20644
2/2
✓ Branch 0 taken 27 times.
✓ Branch 1 taken 93 times.
120 if(s_version > 29)
20645 {
20646
1/2
✓ Branch 0 taken 27 times.
✗ Branch 1 not taken.
27 if(!p_igetl(&temp_zinit.bunny_ltm,f))
20647 {
20648 return qe_invalid;
20649 }
20650 27 }
20651 else
20652 {
20653 93 temp_zinit.bunny_ltm = 0;
20654 }
20655
20656
2/2
✓ Branch 0 taken 27 times.
✓ Branch 1 taken 93 times.
120 if(s_version > 30)
20657 {
20658
1/2
✓ Branch 0 taken 27 times.
✗ Branch 1 not taken.
27 if(!p_getc(&temp_zinit.switchhookstyle,f))
20659 {
20660 return qe_invalid;
20661 }
20662 27 }
20663 else
20664 {
20665 93 temp_zinit.switchhookstyle = 1;
20666 }
20667
20668
2/2
✓ Branch 0 taken 93 times.
✓ Branch 1 taken 27 times.
120 if(s_version > 31)
20669 {
20670
1/2
✓ Branch 0 taken 27 times.
✗ Branch 1 not taken.
27 if(!p_getc(&temp_zinit.magicdrainrate,f))
20671 {
20672 return qe_invalid;
20673 }
20674 27 }
20675
20676 120 temp_zinit.clear_genscript();
20677
2/2
✓ Branch 0 taken 95 times.
✓ Branch 1 taken 25 times.
120 if(s_version > 32)
20678 {
20679 25 word numgenscript = 0;
20680
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
25 if(!p_igetw(&numgenscript,f))
20681 return qe_invalid;
20682
2/4
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 25 times.
25 if (!(numgenscript >= 0 && numgenscript <= NUMSCRIPTSGENERIC))
20683 return qe_invalid;
20684
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 25 times.
25 for(auto q = 1; q < numgenscript; ++q)
20685 {
20686 if(!p_getc(&tempbyte,f))
20687 return qe_invalid;
20688 if(!(tempbyte&2))
20689 continue;
20690 temp_zinit.gen_doscript.set(q, tempbyte&1);
20691 if(!p_igetw(&temp_zinit.gen_exitState[q],f))
20692 return qe_invalid;
20693 if(!p_igetw(&temp_zinit.gen_reloadState[q],f))
20694 return qe_invalid;
20695 for(auto p = 0; p < 8; ++p)
20696 if(!p_igetl(&temp_zinit.gen_initd[q][p],f))
20697 return qe_invalid;
20698 dword sz;
20699 if(!p_igetl(&sz,f))
20700 return qe_invalid;
20701 temp_zinit.gen_data[q].resize(sz);
20702 std::vector<int32_t> dummy;
20703 if(!p_getlvec(&dummy,f))
20704 return qe_invalid;
20705 temp_zinit.gen_data[q] = dummy;
20706 if(!p_igetl(&temp_zinit.gen_eventstate[q],f))
20707 return qe_invalid;
20708 }
20709 25 }
20710
2/2
✓ Branch 0 taken 98 times.
✓ Branch 1 taken 22 times.
120 if(s_version > 33)
20711 {
20712
1/2
✓ Branch 0 taken 22 times.
✗ Branch 1 not taken.
22 if(!p_getc(&temp_zinit.hero_swim_mult,f))
20713 return qe_invalid;
20714
1/2
✓ Branch 0 taken 22 times.
✗ Branch 1 not taken.
22 if(!p_getc(&temp_zinit.hero_swim_div,f))
20715 return qe_invalid;
20716 22 }
20717
1/2
✓ Branch 0 taken 120 times.
✗ Branch 1 not taken.
120 if(s_version > 34)
20718 {
20719 uint32_t num_used_mapscr_data;
20720 if(!p_igetl(&num_used_mapscr_data,f))
20721 return qe_invalid;
20722 for(uint32_t q = 0; q < num_used_mapscr_data; ++q)
20723 {
20724 uint32_t sz;
20725 if(!p_igetl(&sz,f))
20726 return qe_invalid;
20727 temp_zinit.screen_data[q].resize(sz);
20728 if(sz)
20729 {
20730 std::vector<int32_t> dummy;
20731 if(!p_getlvec(&dummy,f))
20732 return qe_invalid;
20733 temp_zinit.screen_data[q] = dummy;
20734 }
20735 }
20736 }
20737
1/2
✓ Branch 0 taken 120 times.
✗ Branch 1 not taken.
120 if (s_version > 35)
20738 if(!p_igetzf(&temp_zinit.shove_offset,f))
20739 return qe_invalid;
20740
20741 120 temp_zinit.counter[crLIFE] *= temp_zinit.hp_per_heart;
20742 120 temp_zinit.mcounter[crLIFE] *= temp_zinit.hp_per_heart;
20743
2/2
✓ Branch 0 taken 57 times.
✓ Branch 1 taken 63 times.
120 if(!temp_zinit.flags.get(INIT_FL_CONTPERCENT))
20744 63 temp_zinit.cont_heart *= temp_zinit.hp_per_heart;
20745
20746 120 return 0;
20747 120 }
20748 128 int32_t readinitdata(PACKFILE *f, zquestheader *Header)
20749 {
20750 128 zinitdata temp_zinit = {};
20751
20752
3/4
✓ Branch 0 taken 124 times.
✓ Branch 1 taken 4 times.
✓ Branch 2 taken 4 times.
✗ Branch 3 not taken.
128 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_initdata);
20753
20754 int32_t dummy;
20755 128 word s_version=0, s_cversion=0;
20756 byte padding;
20757
20758
2/2
✓ Branch 0 taken 124 times.
✓ Branch 1 taken 4 times.
128 if(Header->zelda_version > 0x192)
20759 {
20760
2/4
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 124 times.
✗ Branch 3 not taken.
124 if(!p_igetw(&s_version,f))
20761 return qe_invalid;
20762 124 FFCore.quest_format[vInitData] = s_version;
20763
20764
2/4
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 124 times.
✗ Branch 3 not taken.
124 if(!p_igetw(&s_cversion,f))
20765 return qe_invalid;
20766
20767 //section size
20768
2/4
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 124 times.
✗ Branch 3 not taken.
124 if(!p_igetl(&dummy,f))
20769 return qe_invalid;
20770 124 }
20771
20772
2/2
✓ Branch 0 taken 120 times.
✓ Branch 1 taken 8 times.
128 if(s_version < 37)
20773 {
20774
2/4
✓ Branch 0 taken 120 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 120 times.
120 if(auto ret = readinitdata_old(f,Header,s_version,s_cversion,temp_zinit))
20775 return ret;
20776 120 }
20777 else
20778 {
20779 8 subscr_mode = ssdtMAX;
20780
2/2
✓ Branch 0 taken 256 times.
✓ Branch 1 taken 8 times.
264 for(int q = 0; q < MAXITEMS/8; ++q)
20781
2/4
✓ Branch 0 taken 256 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 256 times.
256 if(!p_getc(&temp_zinit.items[q], f))
20782 return qe_invalid;
20783
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 512 times.
520 for(int q = 0; q < MAXLEVELS/8; ++q)
20784 {
20785
2/4
✓ Branch 0 taken 512 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 512 times.
✗ Branch 3 not taken.
512 if(!p_getc(&temp_zinit.map[q], f))
20786 return qe_invalid;
20787
2/4
✓ Branch 0 taken 512 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 512 times.
512 if(!p_getc(&temp_zinit.compass[q], f))
20788 return qe_invalid;
20789
2/4
✓ Branch 0 taken 512 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 512 times.
512 if(!p_getc(&temp_zinit.boss_key[q], f))
20790 return qe_invalid;
20791
2/4
✓ Branch 0 taken 512 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 512 times.
✗ Branch 3 not taken.
512 if(!p_getc(&temp_zinit.mcguffin[q], f))
20792 return qe_invalid;
20793 512 }
20794
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 if(!p_getbvec(&temp_zinit.level_keys, f))
20795 return qe_invalid;
20796 byte num_counters;
20797
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 if(!p_getc(&num_counters,f))
20798 return qe_invalid;
20799
2/2
✓ Branch 0 taken 856 times.
✓ Branch 1 taken 8 times.
864 for(int q = 0; q < num_counters; ++q)
20800
2/4
✓ Branch 0 taken 856 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 856 times.
856 if(!p_igetw(&temp_zinit.counter[q],f))
20801 return qe_invalid;
20802
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 856 times.
864 for(int q = 0; q < num_counters; ++q)
20803
2/4
✓ Branch 0 taken 856 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 856 times.
856 if(!p_igetw(&temp_zinit.mcounter[q],f))
20804 return qe_invalid;
20805
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 if(!p_getc(&temp_zinit.bomb_ratio,f))
20806 return qe_invalid;
20807
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 if(!p_getc(&temp_zinit.hcp,f))
20808 return qe_invalid;
20809
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 if(!p_getc(&temp_zinit.hcp_per_hc,f))
20810 return qe_invalid;
20811
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 if(!p_igetw(&temp_zinit.cont_heart,f))
20812 return qe_invalid;
20813
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 if(!p_getc(&temp_zinit.hp_per_heart,f))
20814 return qe_invalid;
20815
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 if(!p_getc(&temp_zinit.magic_per_block,f))
20816 return qe_invalid;
20817
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 if(!p_getc(&temp_zinit.hero_damage_multiplier,f))
20818 return qe_invalid;
20819
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 if(!p_getc(&temp_zinit.ene_damage_multiplier,f))
20820 return qe_invalid;
20821
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 if(!p_getc(&temp_zinit.dither_type,f))
20822 return qe_invalid;
20823
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 if(!p_getc(&temp_zinit.dither_arg,f))
20824 return qe_invalid;
20825
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 if(!p_getc(&temp_zinit.dither_percent,f))
20826 return qe_invalid;
20827
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 if(!p_getc(&temp_zinit.def_lightrad,f))
20828 return qe_invalid;
20829
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 if(!p_getc(&temp_zinit.transdark_percent,f))
20830 return qe_invalid;
20831
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 if(!p_getc(&temp_zinit.darkcol,f))
20832 return qe_invalid;
20833
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 if(!p_igetl(&temp_zinit.ss_grid_x,f))
20834 return qe_invalid;
20835
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 if(!p_igetl(&temp_zinit.ss_grid_y,f))
20836 return qe_invalid;
20837
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 if(!p_igetl(&temp_zinit.ss_grid_xofs,f))
20838 return qe_invalid;
20839
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 if(!p_igetl(&temp_zinit.ss_grid_yofs,f))
20840 return qe_invalid;
20841
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 if(!p_igetl(&temp_zinit.ss_grid_color,f))
20842 return qe_invalid;
20843
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 if(!p_igetl(&temp_zinit.ss_bbox_1_color,f))
20844 return qe_invalid;
20845
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 if(!p_igetl(&temp_zinit.ss_bbox_2_color,f))
20846 return qe_invalid;
20847
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 if(!p_igetl(&temp_zinit.ss_flags,f))
20848 return qe_invalid;
20849
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 if(!p_getbitstr(&temp_zinit.flags,f))
20850 return qe_invalid;
20851
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 if(!p_getc(&temp_zinit.last_map,f))
20852 return qe_invalid;
20853
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 if(!p_getc(&temp_zinit.last_screen,f))
20854 return qe_invalid;
20855
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 if(!p_getc(&temp_zinit.msg_more_x,f))
20856 return qe_invalid;
20857
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 if(!p_getc(&temp_zinit.msg_more_y,f))
20858 return qe_invalid;
20859
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 if(!p_getc(&temp_zinit.msg_more_is_offset,f))
20860 return qe_invalid;
20861
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 if(!p_getc(&temp_zinit.msg_speed,f))
20862 return qe_invalid;
20863
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 if(!p_igetl(&temp_zinit.gravity,f))
20864 return qe_invalid;
20865
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 if(!p_igetl(&temp_zinit.swimgravity,f))
20866 return qe_invalid;
20867
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 if(!p_igetw(&temp_zinit.terminalv,f))
20868 return qe_invalid;
20869
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 if(!p_getc(&temp_zinit.hero_swim_speed,f))
20870 return qe_invalid;
20871
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 if(!p_getc(&temp_zinit.hero_swim_mult,f))
20872 return qe_invalid;
20873
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 if(!p_getc(&temp_zinit.hero_swim_div,f))
20874 return qe_invalid;
20875
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 if(!p_igetw(&temp_zinit.heroSideswimUpStep,f))
20876 return qe_invalid;
20877
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 if(!p_igetw(&temp_zinit.heroSideswimSideStep,f))
20878 return qe_invalid;
20879
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 if(!p_igetw(&temp_zinit.heroSideswimDownStep,f))
20880 return qe_invalid;
20881
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 if(!p_igetl(&temp_zinit.exitWaterJump,f))
20882 return qe_invalid;
20883
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 if(!p_igetw(&temp_zinit.heroStep,f))
20884 return qe_invalid;
20885
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 if(!p_getc(&temp_zinit.heroAnimationStyle,f))
20886 return qe_invalid;
20887
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 if(!p_getc(&temp_zinit.jump_hero_layer_threshold,f))
20888 return qe_invalid;
20889
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 if(!p_igetl(&temp_zinit.bunny_ltm,f))
20890 return qe_invalid;
20891
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 if(!p_igetw(&temp_zinit.start_dmap,f))
20892 return qe_invalid;
20893
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 if(!p_igetw(&temp_zinit.subscrSpeed,f))
20894 return qe_invalid;
20895
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 if(!p_getc(&temp_zinit.switchhookstyle,f))
20896 return qe_invalid;
20897
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 if(!p_getc(&temp_zinit.magicdrainrate,f))
20898 return qe_invalid;
20899
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 if(!p_igetzf(&temp_zinit.shove_offset,f))
20900 return qe_invalid;
20901
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 if(!p_getbitstr(&temp_zinit.gen_doscript, f))
20902 return qe_invalid;
20903
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 if(!p_getbmap(&temp_zinit.gen_exitState, f))
20904 return qe_invalid;
20905
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 if(!p_getbmap(&temp_zinit.gen_reloadState, f))
20906 return qe_invalid;
20907
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 if(!p_getbmap(&temp_zinit.gen_initd, f))
20908 return qe_invalid;
20909
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 if(!p_getbmap(&temp_zinit.gen_eventstate, f))
20910 return qe_invalid;
20911
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 if(!p_getbmap(&temp_zinit.gen_data, f))
20912 return qe_invalid;
20913
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 if(!p_getbmap(&temp_zinit.screen_data, f))
20914 return qe_invalid;
20915 }
20916
1/2
✓ Branch 0 taken 128 times.
✗ Branch 1 not taken.
128 if (should_skip)
20917 return 0;
20918
20919
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 128 times.
128 if(loading_tileset_flags & TILESET_CLEARMAPS)
20920 {
20921 temp_zinit.last_map = 0;
20922 temp_zinit.last_screen = 0;
20923 temp_zinit.screen_data.clear();
20924 }
20925
1/2
✓ Branch 0 taken 128 times.
✗ Branch 1 not taken.
128 temp_zinit.normalize();
20926
1/2
✓ Branch 0 taken 128 times.
✗ Branch 1 not taken.
128 zinit = temp_zinit;
20927
20928
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 128 times.
128 if(zinit.heroAnimationStyle==las_zelda3slow)
20929 {
20930 hero_animation_speed=2;
20931 }
20932 else
20933 {
20934 128 hero_animation_speed=1;
20935 }
20936
20937 128 return 0;
20938 128 }
20939
20940 /*
20941 void setupitemdropsets()
20942 {
20943 for(int32_t i=0; i<isMAX; i++)
20944 {
20945 memcpy(&item_drop_sets[i], &default_item_drop_sets[i], sizeof(item_drop_object));
20946 }
20947 }
20948 */
20949
20950 116 int32_t readitemdropsets(PACKFILE *f, int32_t version, word build)
20951 {
20952
2/2
✓ Branch 0 taken 112 times.
✓ Branch 1 taken 4 times.
116 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_itemdropsets);
20953
20954 116 build=build; // here to prevent compiler warnings
20955 dword dummy_dword;
20956 116 word item_drop_sets_to_read=0;
20957 item_drop_object tempitemdrop;
20958 116 word s_version=0, s_cversion=0;
20959
20960
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 116 times.
116 if (!should_skip)
20961
2/2
✓ Branch 0 taken 29696 times.
✓ Branch 1 taken 116 times.
29812 for(int32_t i=0; i<MAXITEMDROPSETS; i++)
20962 {
20963 29696 memset(&item_drop_sets[i], 0, sizeof(item_drop_object));
20964 29812 }
20965
20966
2/2
✓ Branch 0 taken 112 times.
✓ Branch 1 taken 4 times.
116 if(version > 0x192)
20967 {
20968 112 item_drop_sets_to_read=0;
20969
20970 //section version info
20971
1/2
✓ Branch 0 taken 112 times.
✗ Branch 1 not taken.
112 if(!p_igetw(&s_version,f))
20972 {
20973 return qe_invalid;
20974 }
20975
20976 112 FFCore.quest_format[vItemDropsets] = s_version;
20977
20978 //al_trace("Item drop sets version %d\n", s_version);
20979
1/2
✓ Branch 0 taken 112 times.
✗ Branch 1 not taken.
112 if(!p_igetw(&s_cversion,f))
20980 {
20981 return qe_invalid;
20982 }
20983
20984 //section size
20985
1/2
✓ Branch 0 taken 112 times.
✗ Branch 1 not taken.
112 if(!p_igetl(&dummy_dword,f))
20986 {
20987 return qe_invalid;
20988 }
20989
20990 //finally... section data
20991
1/2
✓ Branch 0 taken 112 times.
✗ Branch 1 not taken.
112 if(!p_igetw(&item_drop_sets_to_read,f))
20992 {
20993 return qe_invalid;
20994 }
20995
20996
2/4
✓ Branch 0 taken 112 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 112 times.
✗ Branch 3 not taken.
112 if (!(item_drop_sets_to_read >= 0 && item_drop_sets_to_read <= MAXITEMDROPSETS))
20997 {
20998 return qe_invalid;
20999 }
21000 112 }
21001 else
21002 {
21003 4 init_item_drop_sets();
21004 }
21005
21006
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 112 times.
116 if(s_version>=1)
21007 {
21008
2/2
✓ Branch 0 taken 2056 times.
✓ Branch 1 taken 112 times.
2168 for(int32_t i=0; i<item_drop_sets_to_read; i++)
21009 {
21010
1/2
✓ Branch 0 taken 2056 times.
✗ Branch 1 not taken.
2056 if(!p_getstr(tempitemdrop.name,sizeof(tempitemdrop.name)-1,f))
21011 {
21012 return qe_invalid;
21013 }
21014
21015
2/2
✓ Branch 0 taken 20560 times.
✓ Branch 1 taken 2056 times.
22616 for(int32_t j=0; j<10; ++j)
21016 {
21017
1/2
✓ Branch 0 taken 20560 times.
✗ Branch 1 not taken.
20560 if(!p_igetw(&tempitemdrop.item[j],f))
21018 {
21019 return qe_invalid;
21020 }
21021 20560 }
21022
21023
2/2
✓ Branch 0 taken 22616 times.
✓ Branch 1 taken 2056 times.
24672 for(int32_t j=0; j<11; ++j)
21024 {
21025
1/2
✓ Branch 0 taken 22616 times.
✗ Branch 1 not taken.
22616 if(!p_igetw(&tempitemdrop.chance[j],f))
21026 {
21027 return qe_invalid;
21028 }
21029 22616 }
21030
21031 // Dec 2008: Addition of the 'Tall Grass' set, #12,
21032 // overrides the quest's set #12.
21033
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2056 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2056 if(s_version<2 && i==12)
21034 continue;
21035
21036 // Deprecated: qr_NOCLOCKS and qr_ALLOW10RUPEEDROPS
21037
1/4
✓ Branch 0 taken 2056 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2056 if(s_version<2) for(int32_t j=0; j<10; ++j)
21038 {
21039 int32_t it = tempitemdrop.item[j];
21040
21041 if((itemsbuf[it].family == itype_rupee
21042 && ((itemsbuf[it].amount)&0xFFF) == 10)
21043 && !get_bit(deprecated_rules, qr_ALLOW10RUPEEDROPS_DEP))
21044 {
21045 tempitemdrop.chance[j+1]=0;
21046 }
21047 else if(itemsbuf[it].family == itype_clock && get_bit(deprecated_rules, qr_NOCLOCKS_DEP))
21048 {
21049 tempitemdrop.chance[j+1]=0;
21050 }
21051
21052 // From Sept 2007 to Dec 2008, non-gameplay items were prohibited.
21053 if(itemsbuf[it].family == itype_misc)
21054 {
21055 // If a non-gameplay item was selected, then item drop was aborted.
21056 // Reflect this by increasing the 'Nothing' chance accordingly.
21057 tempitemdrop.chance[0]+=tempitemdrop.chance[j+1];
21058 tempitemdrop.chance[j+1]=0;
21059 }
21060 }
21061
21062
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2056 times.
2056 if (!should_skip)
21063 2056 memcpy(&item_drop_sets[i], &tempitemdrop, sizeof(item_drop_object));
21064 2056 }
21065 112 }
21066
21067 116 return 0;
21068 116 }
21069
21070 112 int32_t readfavorites(PACKFILE *f, int32_t, word)
21071 {
21072
1/2
✓ Branch 0 taken 112 times.
✗ Branch 1 not taken.
112 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_favorites);
21073
21074 int32_t temp_num;
21075 dword dummy_dword;
21076 word num_favorite_combos;
21077 word num_favorite_combo_aliases;
21078 112 word s_version=0, s_cversion=0;
21079
21080 //section version info
21081
1/2
✓ Branch 0 taken 112 times.
✗ Branch 1 not taken.
112 if(!p_igetw(&s_version,f))
21082 {
21083 return qe_invalid;
21084 }
21085
21086
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 112 times.
112 if (!should_skip)
21087 112 FFCore.quest_format[vFavourites] = s_version;
21088
21089
1/2
✓ Branch 0 taken 112 times.
✗ Branch 1 not taken.
112 if(!p_igetw(&s_cversion,f))
21090 {
21091 return qe_invalid;
21092 }
21093
21094 //section size
21095
1/2
✓ Branch 0 taken 112 times.
✗ Branch 1 not taken.
112 if(!p_igetl(&dummy_dword,f))
21096 {
21097 return qe_invalid;
21098 }
21099
21100 112 word per_row = FAVORITECOMBO_PER_ROW;
21101 112 word per_page = FAVORITECOMBO_PER_PAGE;
21102
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 30 times.
112 if(s_version >= 3)
21103
1/2
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
30 if(!p_igetw(&per_row,f))
21104 return qe_invalid;
21105
2/2
✓ Branch 0 taken 104 times.
✓ Branch 1 taken 8 times.
112 if(s_version >= 4)
21106
1/2
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
8 if(!p_igetw(&per_page,f))
21107 return qe_invalid;
21108 //finally... section data
21109
1/2
✓ Branch 0 taken 112 times.
✗ Branch 1 not taken.
112 if(!p_igetw(&num_favorite_combos,f))
21110 {
21111 return qe_invalid;
21112 }
21113
21114 //Hack; port old favorite combos
21115
3/4
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 30 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 82 times.
112 if(s_version < 3 && num_favorite_combos == 100)
21116 82 per_row = 13;
21117
21118
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 112 times.
112 if (!should_skip)
21119
2/2
✓ Branch 0 taken 141120 times.
✓ Branch 1 taken 112 times.
141232 for(int q = 0; q < MAXFAVORITECOMBOS; ++q)
21120 141232 favorite_combos[q] = -1;
21121 112 byte favtype = 0;
21122
2/2
✓ Branch 0 taken 9366 times.
✓ Branch 1 taken 112 times.
9478 for(int32_t i=0; i<num_favorite_combos; i++)
21123 {
21124
2/2
✓ Branch 0 taken 1144 times.
✓ Branch 1 taken 8222 times.
9366 if (s_version >= 4)
21125 {
21126
1/2
✓ Branch 0 taken 1144 times.
✗ Branch 1 not taken.
1144 if (!p_getc(&favtype, f))
21127 {
21128 return qe_invalid;
21129 }
21130 1144 }
21131 else
21132 8222 favtype = 0;
21133
1/2
✓ Branch 0 taken 9366 times.
✗ Branch 1 not taken.
9366 if(!p_igetl(&temp_num,f))
21134 {
21135 return qe_invalid;
21136 }
21137
21138
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9366 times.
9366 if (should_skip)
21139 continue;
21140
21141
2/2
✓ Branch 0 taken 1144 times.
✓ Branch 1 taken 8222 times.
9366 if(per_row == FAVORITECOMBO_PER_ROW)
21142 {
21143 1144 favorite_combos[i] = temp_num;
21144 1144 favorite_combo_modes[i] = favtype;
21145 1144 }
21146 else
21147 {
21148 8222 int new_i = (i%per_row) + (i/per_row)*FAVORITECOMBO_PER_ROW;
21149 8222 favorite_combos[new_i]=temp_num;
21150 8222 favorite_combo_modes[new_i] = favtype;
21151 }
21152 9366 }
21153
21154 // Discard the separate favorite aliases list from previous versions
21155
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 104 times.
112 if(s_version<4)
21156 {
21157
1/2
✓ Branch 0 taken 104 times.
✗ Branch 1 not taken.
104 if (!p_igetw(&num_favorite_combo_aliases, f))
21158 {
21159 return qe_invalid;
21160 }
21161
21162
2/2
✓ Branch 0 taken 8200 times.
✓ Branch 1 taken 104 times.
8304 for (int32_t i = 0; i < num_favorite_combo_aliases; i++)
21163 {
21164
1/2
✓ Branch 0 taken 8200 times.
✗ Branch 1 not taken.
8200 if (!p_igetl(&temp_num, f))
21165 {
21166 return qe_invalid;
21167 }
21168 8200 }
21169 104 }
21170
21171 112 word max_combo_cols = 0;
21172 112 word max_mappages = 0;
21173
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 30 times.
112 if(s_version >= 2)
21174 {
21175
1/2
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
30 if(!p_igetw(&max_combo_cols,f))
21176 return qe_invalid;
21177 30 int32_t tmp = 0, tmp2 = 0, tmp3 = 0;
21178
2/2
✓ Branch 0 taken 120 times.
✓ Branch 1 taken 30 times.
150 for(int q = 0; q < max_combo_cols; ++q)
21179 {
21180
1/2
✓ Branch 0 taken 120 times.
✗ Branch 1 not taken.
120 if(!p_igetl(&tmp,f))
21181 return qe_invalid;
21182
1/2
✓ Branch 0 taken 120 times.
✗ Branch 1 not taken.
120 if(!p_igetl(&tmp2,f))
21183 return qe_invalid;
21184
1/2
✓ Branch 0 taken 120 times.
✗ Branch 1 not taken.
120 if(!p_igetl(&tmp3,f))
21185 return qe_invalid;
21186
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 120 times.
120 if(q < MAX_COMBO_COLS)
21187 {
21188 120 First[q] = tmp;
21189 120 combo_alistpos[q] = tmp2;
21190 120 combo_pool_listpos[q] = tmp3;
21191 120 }
21192 120 }
21193
21194
1/2
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
30 if(!p_igetw(&max_mappages,f))
21195 return qe_invalid;
21196
2/2
✓ Branch 0 taken 270 times.
✓ Branch 1 taken 30 times.
300 for(int q = 0; q < max_mappages; ++q)
21197 {
21198
1/2
✓ Branch 0 taken 270 times.
✗ Branch 1 not taken.
270 if(!p_igetl(&tmp,f))
21199 return qe_invalid;
21200
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 270 times.
270 if(!p_igetl(&tmp2,f))
21201 return qe_invalid;
21202
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 270 times.
270 if(q < MAX_MAPPAGE_BTNS)
21203 {
21204 270 map_page[q].map = tmp;
21205 270 map_page[q].screen = tmp2;
21206 270 }
21207 270 }
21208 30 }
21209
21210
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 112 times.
112 if (should_skip)
21211 return 0;
21212
21213
2/2
✓ Branch 0 taken 328 times.
✓ Branch 1 taken 112 times.
440 for(int q = max_combo_cols; q < MAX_COMBO_COLS; ++q)
21214 {
21215 328 First[q] = 0;
21216 328 combo_alistpos[q] = 0;
21217 328 combo_pool_listpos[q] = 0;
21218 328 }
21219
2/2
✓ Branch 0 taken 738 times.
✓ Branch 1 taken 112 times.
850 for(int q = max_mappages; q < MAX_MAPPAGE_BTNS; ++q)
21220 {
21221 738 map_page[q].map = 0;
21222 738 map_page[q].screen = 0;
21223 738 }
21224
21225 112 return 0;
21226 112 }
21227
21228 /*
21229 switch (ret) {
21230 case 0:
21231 break;
21232
21233 case qe_invalid:
21234 goto invalid;
21235 break;
21236 default:
21237 pack_fclose(f);
21238 if(!oldquest)
21239 delete_file(tmpfilename);
21240 return ret;
21241 break;
21242 }
21243 */
21244
21245 const char *skip_text[skip_max]=
21246 {
21247 "skip_header", "skip_rules", "skip_strings", "skip_misc",
21248 "skip_tiles", "skip_combos", "skip_comboaliases", "skip_csets",
21249 "skip_maps", "skip_dmaps", "skip_doors", "skip_items",
21250 "skip_weapons", "skip_colors", "skip_icons", "skip_initdata",
21251 "skip_guys", "skip_herosprites", "skip_subscreens", "skip_ffscript",
21252 "skip_sfx", "skip_midis", "skip_cheats", "skip_itemdropsets",
21253 "skip_favorites"
21254 };
21255
21256
21257 void port250QuestRules(){
21258
21259 portCandleRules(); //Candle
21260 portBombRules();
21261
21262 }
21263
21264 void portCandleRules()
21265 {
21266 bool hurtshero = get_qr(qr_FIREPROOFHERO);
21267 //itemdata itemsbuf;
21268 for ( int32_t q = 0; q < MAXITEMS; q++ )
21269 {
21270 if ( itemsbuf[q].family == itype_candle )
21271 {
21272 if ( hurtshero ) itemsbuf[q].flags |= ITEM_FLAG2;
21273 else itemsbuf[q].flags &= ~ ITEM_FLAG2;
21274 }
21275 }
21276 }
21277
21278 void portBombRules()
21279 {
21280 bool hurtshero = get_qr(qr_OUCHBOMBS);
21281 //itemdata itemsbuf;
21282 for ( int32_t q = 0; q < MAXITEMS; q++ )
21283 {
21284 if ( itemsbuf[q].family == itype_bomb )
21285 {
21286 if ( hurtshero ) itemsbuf[q].flags |= ITEM_FLAG2;
21287 else itemsbuf[q].flags &= ~ ITEM_FLAG2;
21288 }
21289 }
21290 }
21291
21292 2936 static int section_id_to_enum(int id)
21293 {
21294
24/27
✗ Branch 0 not taken.
✓ Branch 1 taken 128 times.
✓ Branch 2 taken 128 times.
✓ Branch 3 taken 128 times.
✓ Branch 4 taken 128 times.
✓ Branch 5 taken 128 times.
✓ Branch 6 taken 112 times.
✓ Branch 7 taken 128 times.
✓ Branch 8 taken 128 times.
✓ Branch 9 taken 128 times.
✓ Branch 10 taken 128 times.
✓ Branch 11 taken 128 times.
✓ Branch 12 taken 128 times.
✓ Branch 13 taken 112 times.
✓ Branch 14 taken 112 times.
✓ Branch 15 taken 128 times.
✓ Branch 16 taken 128 times.
✓ Branch 17 taken 116 times.
✓ Branch 18 taken 112 times.
✓ Branch 19 taken 112 times.
✓ Branch 20 taken 112 times.
✓ Branch 21 taken 128 times.
✓ Branch 22 taken 128 times.
✓ Branch 23 taken 116 times.
✓ Branch 24 taken 112 times.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
2936 switch (id)
21295 {
21296 case ID_HEADER: return skip_header;
21297 128 case ID_RULES: return skip_rules;
21298 128 case ID_STRINGS: return skip_strings;
21299 128 case ID_MISC: return skip_misc;
21300 128 case ID_TILES: return skip_tiles;
21301 128 case ID_COMBOS: return skip_combos;
21302 112 case ID_COMBOALIASES: return skip_comboaliases;
21303 128 case ID_CSETS: return skip_csets;
21304 128 case ID_MAPS: return skip_maps;
21305 128 case ID_DMAPS: return skip_dmaps;
21306 128 case ID_DOORS: return skip_doors;
21307 128 case ID_ITEMS: return skip_items;
21308 128 case ID_WEAPONS: return skip_weapons;
21309 112 case ID_COLORS: return skip_colors;
21310 112 case ID_ICONS: return skip_icons;
21311 128 case ID_INITDATA: return skip_initdata;
21312 128 case ID_GUYS: return skip_guys;
21313 116 case ID_HEROSPRITES: return skip_herosprites;
21314 112 case ID_SUBSCREEN: return skip_subscreens;
21315 112 case ID_FFSCRIPT: return skip_ffscript;
21316 112 case ID_SFX: return skip_sfx;
21317 128 case ID_MIDIS: return skip_midis;
21318 128 case ID_CHEATS: return skip_cheats;
21319 116 case ID_ITEMDROPSETS: return skip_itemdropsets;
21320 112 case ID_FAVORITES: return skip_favorites;
21321 case ID_ZINFO: return skip_zinfo;
21322 }
21323
21324 return -1;
21325 2936 }
21326
21327 2868 static int maybe_skip_section(PACKFILE* f, dword& section_id, const byte* skip_flags)
21328 {
21329 2868 int section_enum = section_id_to_enum(section_id);
21330
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2868 times.
2868 bool skip = section_enum >= 0 && get_bit(skip_flags, section_enum);
21331
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2868 times.
2868 if (skip)
21332 {
21333 word s_version;
21334 if (!p_igetw(&s_version,f))
21335 {
21336 return qe_invalid;
21337 }
21338
21339 word c_version;
21340 if (!p_igetw(&c_version,f))
21341 {
21342 return qe_invalid;
21343 }
21344
21345 if (section_id == ID_RULES && s_version > 16)
21346 {
21347 dword dummy;
21348 if (!p_igetl(&dummy,f))
21349 {
21350 return qe_invalid;
21351 }
21352 }
21353
21354 if (section_id == ID_FFSCRIPT && s_version >= 18)
21355 {
21356 word dummy;
21357 if (!p_igetw(&dummy,f))
21358 {
21359 return qe_invalid;
21360 }
21361 }
21362
21363 dword section_length;
21364 if (!p_igetl(&section_length,f))
21365 {
21366 return qe_invalid;
21367 }
21368
21369 if (pack_fseek(f, section_length))
21370 {
21371 return qe_invalid;
21372 }
21373
21374 if (!pack_feof(f))
21375 {
21376 if (!p_mgetl(&section_id,f))
21377 {
21378 return qe_invalid;
21379 }
21380 }
21381
21382 return qe_cancel;
21383 }
21384
21385 2868 return qe_OK;
21386 2868 }
21387
21388 //Internal function for loadquest wrapper
21389 128 static int32_t _lq_int(const char *filename, zquestheader *Header, miscQdata *Misc, zctune *tunes, bool show_progress, byte *skip_flags, byte printmetadata)
21390 {
21391 128 DMapEditorLastMaptileUsed = 0;
21392 128 combosread=false;
21393 128 mapsread=false;
21394 128 fixffcs=false;
21395
21396 128 bool do_clear_scripts = !get_bit(skip_flags,skip_ffscript);
21397
1/2
✓ Branch 0 taken 128 times.
✗ Branch 1 not taken.
128 if(loading_tileset_flags & TILESET_CLEARSCRIPTS)
21398 {
21399 set_bit(skip_flags, skip_ffscript, 1);
21400 setZScriptVersion(V_FFSCRIPT);
21401 FFCore.quest_format[vFFScript] = V_FFSCRIPT;
21402 FFCore.quest_format[vLastCompile] = V_FFSCRIPT;
21403 do_clear_scripts = true;
21404 }
21405
1/2
✓ Branch 0 taken 128 times.
✗ Branch 1 not taken.
128 if(loading_tileset_flags & TILESET_CLEARMAPS)
21406 {
21407 set_bit(skip_flags, skip_maps, 1);
21408 }
21409
21410 // show_progress=true;
21411 char tmpfilename[L_tmpnam];
21412 128 temp_name(tmpfilename);
21413 // char percent_done[30];
21414 128 bool catchup=false;
21415 byte tempbyte;
21416 128 word old_map_count=map_count;
21417
21418 128 byte old_quest_rules[QUESTRULES_NEW_SIZE] = {0};
21419 128 byte old_extra_rules[EXTRARULES_SIZE] = {0};
21420 128 byte old_midi_flags[MIDIFLAGS_SIZE] = {0};
21421
21422
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 128 times.
128 if(get_bit(skip_flags, skip_rules))
21423 {
21424 memcpy(old_quest_rules, quest_rules, QUESTRULES_NEW_SIZE);
21425 memcpy(old_extra_rules, extra_rules, EXTRARULES_SIZE);
21426 }
21427
21428 128 memset(quest_rules, 0, QUESTRULES_NEW_SIZE); //clear here to prevent any kind of carryover -Z
21429 // memset(extra_rules, 0, EXTRARULES_SIZE); //clear here to prevent any kind of carryover -Z
21430
21431
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 128 times.
128 if(get_bit(skip_flags, skip_midis))
21432 {
21433 memcpy(old_midi_flags, midi_flags, MIDIFLAGS_SIZE);
21434 }
21435
21436
21437
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 128 times.
128 if(do_clear_scripts)
21438 {
21439 128 zScript.clear();
21440 128 globalmap.clear();
21441 128 genericmap.clear();
21442 128 ffcmap.clear();
21443 128 itemmap.clear();
21444 128 npcmap.clear();
21445 128 ewpnmap.clear();
21446 128 lwpnmap.clear();
21447 128 playermap.clear();
21448 128 dmapmap.clear();
21449 128 screenmap.clear();
21450 128 itemspritemap.clear();
21451 128 comboscriptmap.clear();
21452 128 subscreenmap.clear();
21453
21454
2/2
✓ Branch 0 taken 65408 times.
✓ Branch 1 taken 128 times.
65536 for(int32_t i=0; i<NUMSCRIPTFFC-1; i++)
21455 {
21456 65408 ffcmap[i].clear();
21457 65408 }
21458
21459 128 globalmap[0].slotname = "Slot 1:";
21460 128 globalmap[0].scriptname = "~Init";
21461 128 globalmap[0].update();
21462
21463
2/2
✓ Branch 0 taken 896 times.
✓ Branch 1 taken 128 times.
1024 for(int32_t i=1; i<NUMSCRIPTGLOBAL; i++)
21464 {
21465 896 globalmap[i].clear();
21466 896 }
21467
21468
2/2
✓ Branch 0 taken 32640 times.
✓ Branch 1 taken 128 times.
32768 for(int32_t i=0; i<NUMSCRIPTITEM-1; i++)
21469 {
21470 32640 itemmap[i].clear();
21471 32640 }
21472
21473 //new script types -- prevent carrying over to a quest that you load after reading them
21474 //e.g., a quest has an npc script, and you make a blank quest, that now believes that it has an npc script, too!
21475
2/2
✓ Branch 0 taken 32640 times.
✓ Branch 1 taken 128 times.
32768 for(int32_t i=0; i<NUMSCRIPTGUYS-1; i++)
21476 {
21477 32640 npcmap[i].clear();
21478 32640 }
21479
2/2
✓ Branch 0 taken 32640 times.
✓ Branch 1 taken 128 times.
32768 for(int32_t i=0; i<NUMSCRIPTWEAPONS-1; i++)
21480 {
21481 32640 lwpnmap[i].clear();
21482 32640 }
21483
2/2
✓ Branch 0 taken 32640 times.
✓ Branch 1 taken 128 times.
32768 for(int32_t i=0; i<NUMSCRIPTWEAPONS-1; i++)
21484 {
21485 32640 ewpnmap[i].clear();
21486 32640 }
21487
2/2
✓ Branch 0 taken 512 times.
✓ Branch 1 taken 128 times.
640 for(int32_t i=0; i<NUMSCRIPTPLAYER-1; i++)
21488 {
21489 512 playermap[i].clear();
21490 512 }
21491
2/2
✓ Branch 0 taken 32640 times.
✓ Branch 1 taken 128 times.
32768 for(int32_t i=0; i<NUMSCRIPTSDMAP-1; i++)
21492 {
21493 32640 dmapmap[i].clear();
21494 32640 }
21495
2/2
✓ Branch 0 taken 32640 times.
✓ Branch 1 taken 128 times.
32768 for(int32_t i=0; i<NUMSCRIPTSCREEN-1; i++)
21496 {
21497 32640 screenmap[i].clear();
21498 32640 }
21499
2/2
✓ Branch 0 taken 32640 times.
✓ Branch 1 taken 128 times.
32768 for(int32_t i=0; i<NUMSCRIPTSITEMSPRITE-1; i++)
21500 {
21501 32640 itemspritemap[i].clear();
21502 32640 }
21503
2/2
✓ Branch 0 taken 65408 times.
✓ Branch 1 taken 128 times.
65536 for(int32_t i=0; i<NUMSCRIPTSCOMBODATA-1; i++)
21504 {
21505 65408 comboscriptmap[i].clear();
21506 65408 }
21507
2/2
✓ Branch 0 taken 65408 times.
✓ Branch 1 taken 128 times.
65536 for(int32_t i=0; i<NUMSCRIPTSGENERIC-1; i++)
21508 {
21509 65408 genericmap[i].clear();
21510 65408 }
21511
2/2
✓ Branch 0 taken 32640 times.
✓ Branch 1 taken 128 times.
32768 for(int32_t i=0; i<NUMSCRIPTSSUBSCREEN-1; i++)
21512 {
21513 32640 subscreenmap[i].clear();
21514 32640 }
21515
21516 128 reset_scripts();
21517 128 }
21518
21519 zquestheader tempheader;
21520 128 memset(&tempheader, 0, sizeof(zquestheader));
21521 128 zinfo tempzi;
21522 128 tempzi.clear();
21523 128 load_tmp_zi = &tempzi;
21524
21525 // oldquest flag is set when an unencrypted qst file is suspected.
21526 128 bool oldquest = false;
21527 128 int32_t open_error=0;
21528 128 PACKFILE *f=open_quest_file(&open_error, filename, show_progress);
21529
21530
1/2
✓ Branch 0 taken 128 times.
✗ Branch 1 not taken.
128 if (!f)
21531 {
21532 ASSERT(open_error != 0);
21533 return open_error;
21534 }
21535 char zinfofilename[2048];
21536 128 replace_extension(zinfofilename, filename, "zinfo", 2047);
21537 128 int32_t ret=0;
21538
21539 //header
21540 128 box_out("Reading Header...");
21541 128 ret=readheader(f, &tempheader, printmetadata);
21542
1/5
✗ Branch 0 not taken.
✓ Branch 1 taken 128 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
128 checkstatus(ret);
21543 128 box_out("okay.");
21544 128 box_eol();
21545
21546
2/2
✓ Branch 0 taken 93 times.
✓ Branch 1 taken 35 times.
128 if(read_zinfo)
21547 {
21548 35 box_out("Reading ZInfo - ");
21549
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 34 times.
35 box_out(read_ext_zinfo ? "External..." : "Internal...");
21550
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 34 times.
35 if(read_ext_zinfo)
21551 {
21552 1 PACKFILE *inf=pack_fopen_password(zinfofilename, F_READ, "");
21553 1 ret=readzinfo(inf, tempzi, tempheader);
21554
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if(inf) pack_fclose(inf);
21555
1/5
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
1 checkstatus(ret);
21556 1 }
21557 else
21558 {
21559 34 ret=readzinfo(f, tempzi, tempheader);
21560
1/5
✗ Branch 0 not taken.
✓ Branch 1 taken 34 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
34 checkstatus(ret);
21561 }
21562 35 box_out("okay.");
21563 35 box_eol();
21564 35 }
21565
21566
2/2
✓ Branch 0 taken 124 times.
✓ Branch 1 taken 4 times.
128 if(tempheader.zelda_version>=0x193)
21567 {
21568 dword section_id;
21569
21570 //section id
21571
1/2
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
124 if(!p_mgetl(&section_id,f))
21572 {
21573 return qe_invalid;
21574 }
21575
21576 124 std::set<dword> seen_sections;
21577
21578
3/4
✓ Branch 0 taken 2992 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2868 times.
✓ Branch 3 taken 124 times.
2992 while(!pack_feof(f))
21579 {
21580
2/4
✓ Branch 0 taken 2868 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2868 times.
✗ Branch 3 not taken.
2868 if (seen_sections.contains(section_id))
21581 return qe_invalid;
21582
1/2
✓ Branch 0 taken 2868 times.
✗ Branch 1 not taken.
2868 seen_sections.insert(section_id);
21583
21584
2/4
✓ Branch 0 taken 2868 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2868 times.
✗ Branch 3 not taken.
2868 if (int retval = maybe_skip_section(f, section_id, skip_flags); retval != qe_OK)
21585 {
21586 if (retval == qe_cancel)
21587 continue;
21588 checkstatus(retval);
21589 }
21590
21591
24/25
✓ Branch 0 taken 124 times.
✓ Branch 1 taken 124 times.
✓ Branch 2 taken 124 times.
✓ Branch 3 taken 124 times.
✓ Branch 4 taken 124 times.
✓ Branch 5 taken 112 times.
✓ Branch 6 taken 124 times.
✓ Branch 7 taken 124 times.
✓ Branch 8 taken 124 times.
✓ Branch 9 taken 124 times.
✓ Branch 10 taken 124 times.
✓ Branch 11 taken 124 times.
✓ Branch 12 taken 112 times.
✓ Branch 13 taken 112 times.
✓ Branch 14 taken 124 times.
✓ Branch 15 taken 124 times.
✓ Branch 16 taken 112 times.
✓ Branch 17 taken 112 times.
✓ Branch 18 taken 112 times.
✓ Branch 19 taken 112 times.
✓ Branch 20 taken 124 times.
✓ Branch 21 taken 124 times.
✓ Branch 22 taken 112 times.
✓ Branch 23 taken 112 times.
✗ Branch 24 not taken.
2868 switch(section_id)
21592 {
21593 case ID_RULES:
21594
21595 //rules
21596
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 124 times.
124 if(catchup)
21597 {
21598 box_out("found.");
21599 box_eol();
21600 catchup=false;
21601 }
21602
21603
1/2
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
124 box_out("Reading Rules...");
21604
1/2
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
124 ret=readrules(f, &tempheader);
21605
1/9
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
124 checkstatus(ret);
21606
1/2
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
124 box_out("okay.");
21607
1/2
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
124 box_eol();
21608 124 break;
21609
21610 case ID_STRINGS:
21611
21612 //strings
21613
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 124 times.
124 if(catchup)
21614 {
21615 box_out("found.");
21616 box_eol();
21617 catchup=false;
21618 }
21619
21620
1/2
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
124 box_out("Reading Strings...");
21621
1/2
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
124 ret=readstrings(f, &tempheader);
21622
1/9
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
124 checkstatus(ret);
21623
1/2
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
124 box_out("okay.");
21624
1/2
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
124 box_eol();
21625 124 break;
21626
21627 case ID_MISC:
21628
21629 //misc data
21630
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 124 times.
124 if(catchup)
21631 {
21632 box_out("found.");
21633 box_eol();
21634 catchup=false;
21635 }
21636
21637
1/2
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
124 box_out("Reading Misc. Data...");
21638
1/2
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
124 ret=readmisc(f, &tempheader, Misc);
21639
1/9
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
124 checkstatus(ret);
21640
1/2
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
124 box_out("okay.");
21641
1/2
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
124 box_eol();
21642 124 break;
21643
21644 case ID_TILES:
21645
21646 //tiles
21647
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 124 times.
124 if(catchup)
21648 {
21649 box_out("found.");
21650 box_eol();
21651 catchup=false;
21652 }
21653
21654
1/2
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
124 box_out("Reading Tiles...");
21655
1/2
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
124 ret=readtiles(f, newtilebuf, &tempheader, tempheader.zelda_version, tempheader.build, 0, NEWMAXTILES, false);
21656
1/9
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 124 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
124 checkstatus(ret);
21657
1/2
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
124 box_out("okay.");
21658
1/2
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
124 box_eol();
21659 124 break;
21660
21661 case ID_COMBOS:
21662
21663 //combos
21664
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 124 times.
124 if(catchup)
21665 {
21666 box_out("found.");
21667 box_eol();
21668 catchup=false;
21669 }
21670
21671
1/2
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
124 box_out("Reading Combos...");
21672
1/2
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
124 ret=readcombos(f, &tempheader, tempheader.zelda_version, tempheader.build, 0, MAXCOMBOS);
21673 124 combosread=true;
21674
1/9
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
124 checkstatus(ret);
21675
1/2
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
124 box_out("okay.");
21676
1/2
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
124 box_eol();
21677 124 break;
21678
21679 case ID_COMBOALIASES:
21680
21681 //combo aliases
21682
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 112 times.
112 if(catchup)
21683 {
21684 box_out("found.");
21685 box_eol();
21686 catchup=false;
21687 }
21688
21689
1/2
✓ Branch 0 taken 112 times.
✗ Branch 1 not taken.
112 box_out("Reading Combo Aliases...");
21690
1/2
✓ Branch 0 taken 112 times.
✗ Branch 1 not taken.
112 ret=readcomboaliases(f, &tempheader, tempheader.zelda_version, tempheader.build);
21691
1/9
✓ Branch 0 taken 112 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
112 checkstatus(ret);
21692
1/2
✓ Branch 0 taken 112 times.
✗ Branch 1 not taken.
112 box_out("okay.");
21693
1/2
✓ Branch 0 taken 112 times.
✗ Branch 1 not taken.
112 box_eol();
21694 112 break;
21695
21696 case ID_CSETS:
21697
21698 //color data
21699
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 124 times.
124 if(catchup)
21700 {
21701 box_out("found.");
21702 box_eol();
21703 catchup=false;
21704 }
21705
21706
1/2
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
124 box_out("Reading Color Data...");
21707
1/2
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
124 ret=readcolordata(f, Misc, tempheader.zelda_version, tempheader.build, 0, newerpdTOTAL);
21708
1/9
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
124 checkstatus(ret);
21709
1/2
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
124 box_out("okay.");
21710
1/2
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
124 box_eol();
21711 124 break;
21712
21713 case ID_MAPS:
21714
21715 //maps
21716
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 124 times.
124 if(catchup)
21717 {
21718 box_out("found.");
21719 box_eol();
21720 catchup=false;
21721 }
21722
21723
1/2
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
124 box_out("Reading Maps...");
21724
1/2
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
124 ret=readmaps(f, &tempheader);
21725 124 mapsread=true;
21726
1/9
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
124 checkstatus(ret);
21727
1/2
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
124 box_out("okay.");
21728
1/2
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
124 box_eol();
21729 124 break;
21730
21731 case ID_DMAPS:
21732
21733 //dmaps
21734
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 124 times.
124 if(catchup)
21735 {
21736 box_out("found.");
21737 box_eol();
21738 catchup=false;
21739 }
21740
21741
1/2
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
124 box_out("Reading DMaps...");
21742
1/2
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
124 ret=readdmaps(f, &tempheader, tempheader.zelda_version, tempheader.build, 0, MAXDMAPS);
21743
1/9
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
124 checkstatus(ret);
21744
1/2
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
124 box_out("okay.");
21745
1/2
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
124 box_eol();
21746 124 break;
21747
21748 case ID_DOORS:
21749
21750 //door combo sets
21751
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 124 times.
124 if(catchup)
21752 {
21753 box_out("found.");
21754 box_eol();
21755 catchup=false;
21756 }
21757
21758
1/2
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
124 box_out("Reading Doors...");
21759
1/2
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
124 ret=readdoorcombosets(f, &tempheader);
21760
1/9
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
124 checkstatus(ret);
21761
1/2
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
124 box_out("okay.");
21762
1/2
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
124 box_eol();
21763 124 break;
21764
21765 case ID_ITEMS:
21766
21767 //items
21768
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 124 times.
124 if(catchup)
21769 {
21770 box_out("found.");
21771 box_eol();
21772 catchup=false;
21773 }
21774
21775
1/2
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
124 box_out("Reading Items...");
21776
1/2
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
124 ret=readitems(f, tempheader.zelda_version, tempheader.build);
21777
1/9
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
124 checkstatus(ret);
21778
21779
1/2
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
124 box_out("okay.");
21780
1/2
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
124 box_eol();
21781 124 break;
21782
21783 case ID_WEAPONS:
21784
21785 //weapons
21786
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 124 times.
124 if(catchup)
21787 {
21788 box_out("found.");
21789 box_eol();
21790 catchup=false;
21791 }
21792
21793
1/2
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
124 box_out("Reading Weapons...");
21794
1/2
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
124 ret=readweapons(f, &tempheader);
21795
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 124 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
124 checkstatus(ret);
21796
1/2
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
124 box_out("okay.");
21797
1/2
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
124 box_eol();
21798 124 break;
21799
21800 case ID_COLORS:
21801
21802 //misc. colors
21803
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 112 times.
112 if(catchup)
21804 {
21805 box_out("found.");
21806 box_eol();
21807 catchup=false;
21808 }
21809
21810
1/2
✓ Branch 0 taken 112 times.
✗ Branch 1 not taken.
112 box_out("Reading Misc. Colors...");
21811
1/2
✓ Branch 0 taken 112 times.
✗ Branch 1 not taken.
112 ret=readmisccolors(f, &tempheader, Misc);
21812
1/9
✓ Branch 0 taken 112 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
112 checkstatus(ret);
21813
1/2
✓ Branch 0 taken 112 times.
✗ Branch 1 not taken.
112 box_out("okay.");
21814
1/2
✓ Branch 0 taken 112 times.
✗ Branch 1 not taken.
112 box_eol();
21815 112 break;
21816
21817 case ID_ICONS:
21818
21819 //game icons
21820
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 112 times.
112 if(catchup)
21821 {
21822 box_out("found.");
21823 box_eol();
21824 catchup=false;
21825 }
21826
21827
1/2
✓ Branch 0 taken 112 times.
✗ Branch 1 not taken.
112 box_out("Reading Game Icons...");
21828
1/2
✓ Branch 0 taken 112 times.
✗ Branch 1 not taken.
112 ret=readgameicons(f, &tempheader, Misc);
21829
1/9
✓ Branch 0 taken 112 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
112 checkstatus(ret);
21830
1/2
✓ Branch 0 taken 112 times.
✗ Branch 1 not taken.
112 box_out("okay.");
21831
1/2
✓ Branch 0 taken 112 times.
✗ Branch 1 not taken.
112 box_eol();
21832 112 break;
21833
21834 case ID_INITDATA:
21835
21836 //initialization data
21837
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 124 times.
124 if(catchup)
21838 {
21839 box_out("found.");
21840 box_eol();
21841 catchup=false;
21842 }
21843
21844
1/2
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
124 box_out("Reading Init. Data...");
21845
1/2
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
124 ret=readinitdata(f, &tempheader);
21846
1/9
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 124 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
124 checkstatus(ret);
21847
1/2
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
124 box_out("okay.");
21848
1/2
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
124 box_eol();
21849
21850
2/4
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 124 times.
124 if(!get_bit(skip_flags, skip_subscreens))
21851 {
21852
2/2
✓ Branch 0 taken 27 times.
✓ Branch 1 taken 97 times.
124 if(subscr_mode!=ssdtMAX) //not using custom subscreens
21853 {
21854
1/2
✓ Branch 0 taken 27 times.
✗ Branch 1 not taken.
27 setupsubscreens();
21855
21856
2/2
✓ Branch 0 taken 13824 times.
✓ Branch 1 taken 27 times.
13851 for(int32_t i=0; i<MAXDMAPS; ++i)
21857 {
21858 13824 int32_t type=DMaps[i].type&dmfTYPE;
21859
2/2
✓ Branch 0 taken 207 times.
✓ Branch 1 taken 13617 times.
13824 DMaps[i].active_subscreen=(type == dmOVERW || type == dmBSOVERW)?0:1;
21860
1/2
✓ Branch 0 taken 13824 times.
✗ Branch 1 not taken.
13824 DMaps[i].passive_subscreen=(get_qr(qr_ENABLEMAGIC))?0:1;
21861 13824 }
21862 27 }
21863 124 }
21864
21865
2/4
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 124 times.
124 if(!get_bit(skip_flags, skip_sfx))
21866 {
21867 124 setupsfx();
21868 124 }
21869
21870
2/4
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 124 times.
✗ Branch 3 not taken.
124 if(!get_bit(skip_flags, skip_itemdropsets))
21871 {
21872
1/2
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
124 init_item_drop_sets();
21873 124 }
21874
21875
2/4
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 124 times.
124 if(!get_bit(skip_flags, skip_favorites))
21876 {
21877 124 init_favorites();
21878 124 }
21879
21880 124 break;
21881
21882 case ID_GUYS:
21883
21884 //guys
21885
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 124 times.
124 if(catchup)
21886 {
21887 box_out("found.");
21888 box_eol();
21889 catchup=false;
21890 }
21891
21892
1/2
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
124 box_out("Reading Custom Guy Data...");
21893
1/2
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
124 ret=readguys(f, &tempheader);
21894
1/9
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
124 checkstatus(ret);
21895
1/2
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
124 box_out("okay.");
21896
1/2
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
124 box_eol();
21897 124 break;
21898
21899 case ID_HEROSPRITES:
21900
21901 //player sprites
21902
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 112 times.
112 if(catchup)
21903 {
21904 box_out("found.");
21905 box_eol();
21906 catchup=false;
21907 }
21908
21909
1/2
✓ Branch 0 taken 112 times.
✗ Branch 1 not taken.
112 box_out("Reading Custom Player Sprite Data...");
21910
1/2
✓ Branch 0 taken 112 times.
✗ Branch 1 not taken.
112 ret=readherosprites(f, &tempheader);
21911
1/9
✓ Branch 0 taken 112 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
112 checkstatus(ret);
21912
1/2
✓ Branch 0 taken 112 times.
✗ Branch 1 not taken.
112 box_out("okay.");
21913
1/2
✓ Branch 0 taken 112 times.
✗ Branch 1 not taken.
112 box_eol();
21914 112 break;
21915
21916 case ID_SUBSCREEN:
21917
21918 //custom subscreens
21919
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 112 times.
112 if(catchup)
21920 {
21921 box_out("found.");
21922 box_eol();
21923 catchup=false;
21924 }
21925
21926
1/2
✓ Branch 0 taken 112 times.
✗ Branch 1 not taken.
112 box_out("Reading Custom Subscreen Data...");
21927
1/2
✓ Branch 0 taken 112 times.
✗ Branch 1 not taken.
112 ret=readsubscreens(f);
21928
1/9
✓ Branch 0 taken 112 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
112 checkstatus(ret);
21929
1/2
✓ Branch 0 taken 112 times.
✗ Branch 1 not taken.
112 box_out("okay.");
21930
1/2
✓ Branch 0 taken 112 times.
✗ Branch 1 not taken.
112 box_eol();
21931 112 break;
21932
21933 case ID_FFSCRIPT:
21934
21935 //Freeform combo scripts
21936
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 112 times.
112 if(catchup)
21937 {
21938 box_out("found.");
21939 box_eol();
21940 catchup=false;
21941 }
21942
21943
1/2
✓ Branch 0 taken 112 times.
✗ Branch 1 not taken.
112 box_out("Reading FF Script Data...");
21944
1/2
✓ Branch 0 taken 112 times.
✗ Branch 1 not taken.
112 ret=readffscript(f, &tempheader);
21945
1/9
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 112 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
112 checkstatus(ret);
21946
1/2
✓ Branch 0 taken 112 times.
✗ Branch 1 not taken.
112 box_out("okay.");
21947
1/2
✓ Branch 0 taken 112 times.
✗ Branch 1 not taken.
112 box_eol();
21948 112 break;
21949
21950 case ID_SFX:
21951
21952 //SFX data
21953
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 112 times.
112 if(catchup)
21954 {
21955 box_out("found.");
21956 box_eol();
21957 catchup=false;
21958 }
21959
21960
1/2
✓ Branch 0 taken 112 times.
✗ Branch 1 not taken.
112 box_out("Reading SFX Data...");
21961
1/2
✓ Branch 0 taken 112 times.
✗ Branch 1 not taken.
112 ret=readsfx(f, &tempheader);
21962
1/9
✓ Branch 0 taken 112 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
112 checkstatus(ret);
21963
1/2
✓ Branch 0 taken 112 times.
✗ Branch 1 not taken.
112 box_out("okay.");
21964
1/2
✓ Branch 0 taken 112 times.
✗ Branch 1 not taken.
112 box_eol();
21965 112 break;
21966
21967 case ID_MIDIS:
21968
21969 //midis
21970
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 124 times.
124 if(catchup)
21971 {
21972 box_out("found.");
21973 box_eol();
21974 catchup=false;
21975 }
21976
21977
1/2
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
124 box_out("Reading Tunes...");
21978
1/2
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
124 ret=readtunes(f, &tempheader, tunes);
21979
1/9
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
124 checkstatus(ret);
21980
1/2
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
124 box_out("okay.");
21981
1/2
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
124 box_eol();
21982 124 break;
21983
21984 case ID_CHEATS:
21985
21986 //cheat codes
21987
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 124 times.
124 if(catchup)
21988 {
21989 box_out("found.");
21990 box_eol();
21991 catchup=false;
21992 }
21993
21994
1/2
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
124 box_out("Reading Cheat Codes...");
21995
1/2
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
124 ret=readcheatcodes(f, &tempheader);
21996
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 124 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
124 checkstatus(ret);
21997
1/2
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
124 box_out("okay.");
21998
1/2
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
124 box_eol();
21999 124 break;
22000
22001 case ID_ITEMDROPSETS:
22002
22003 //item drop sets
22004
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 112 times.
112 if(catchup)
22005 {
22006 box_out("found.");
22007 box_eol();
22008 catchup=false;
22009 }
22010
22011
1/2
✓ Branch 0 taken 112 times.
✗ Branch 1 not taken.
112 box_out("Reading Item Drop Sets...");
22012
1/2
✓ Branch 0 taken 112 times.
✗ Branch 1 not taken.
112 ret=readitemdropsets(f, tempheader.zelda_version, tempheader.build);
22013
1/9
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 112 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
112 checkstatus(ret);
22014
1/2
✓ Branch 0 taken 112 times.
✗ Branch 1 not taken.
112 box_out("okay.");
22015
1/2
✓ Branch 0 taken 112 times.
✗ Branch 1 not taken.
112 box_eol();
22016 112 break;
22017
22018 case ID_FAVORITES:
22019
22020 //favorite combos and combo aliases
22021
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 112 times.
112 if(catchup)
22022 {
22023 box_out("found.");
22024 box_eol();
22025 catchup=false;
22026 }
22027
22028
1/2
✓ Branch 0 taken 112 times.
✗ Branch 1 not taken.
112 box_out("Reading Favorite Combos...");
22029
1/2
✓ Branch 0 taken 112 times.
✗ Branch 1 not taken.
112 ret=readfavorites(f, tempheader.zelda_version, tempheader.build);
22030
1/9
✓ Branch 0 taken 112 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
112 checkstatus(ret);
22031
1/2
✓ Branch 0 taken 112 times.
✗ Branch 1 not taken.
112 box_out("okay.");
22032
1/2
✓ Branch 0 taken 112 times.
✗ Branch 1 not taken.
112 box_eol();
22033 112 break;
22034
22035 default:
22036 if(!catchup)
22037 {
22038 box_out("Bad token! Searching...");
22039 box_eol();
22040 }
22041
22042 catchup=true;
22043 break;
22044 }
22045
22046
22047
1/2
✓ Branch 0 taken 2868 times.
✗ Branch 1 not taken.
2868 if(catchup)
22048 {
22049 //section id
22050 section_id=(section_id<<8);
22051
22052 if(!p_getc(&tempbyte,f))
22053 {
22054 return qe_invalid;
22055 }
22056
22057 section_id+=tempbyte;
22058 }
22059
22060 else
22061 {
22062 //section id
22063
3/4
✓ Branch 0 taken 2868 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2744 times.
✓ Branch 3 taken 124 times.
2868 if(!pack_feof(f))
22064 {
22065
2/4
✓ Branch 0 taken 2744 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2744 times.
✗ Branch 3 not taken.
2744 if(!p_mgetl(&section_id,f))
22066 {
22067 return qe_invalid;
22068 }
22069 2744 }
22070 }
22071 }
22072
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 124 times.
124 }
22073 else
22074 {
22075
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 std::vector<std::tuple<std::string, int32_t, std::function<int32_t()>>> hardcoded_sections = {
22076
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
8 { "Rules", ID_RULES, [&](){ return readrules(f, &tempheader); }},
22077
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
8 { "Strings", ID_STRINGS, [&](){ return readstrings(f, &tempheader); }},
22078
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
8 { "Doors", ID_DOORS, [&](){ return readdoorcombosets(f, &tempheader); }},
22079
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
8 { "DMaps", ID_DMAPS, [&](){ return readdmaps(f, &tempheader, tempheader.zelda_version, tempheader.build, 0, MAXDMAPS); }},
22080
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
8 { "Misc. Data", ID_MISC, [&](){ return readmisc(f, &tempheader, Misc); }},
22081
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
8 { "Items", ID_ITEMS, [&](){ return readitems(f, tempheader.zelda_version, tempheader.build); }},
22082
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
8 { "Weapons", ID_WEAPONS, [&](){ return readweapons(f, &tempheader); }},
22083
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
8 { "Custom Guy Data", ID_GUYS, [&](){ return readguys(f, &tempheader); }},
22084
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
8 { "Maps", ID_MAPS, [&](){ return readmaps(f, &tempheader); }},
22085
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
8 { "Combos", ID_COMBOS, [&](){ return readcombos(f, &tempheader, tempheader.zelda_version, tempheader.build, 0, MAXCOMBOS); }},
22086
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
8 { "Color Data", ID_CSETS, [&](){ return readcolordata(f, Misc, tempheader.zelda_version, tempheader.build, 0, newerpdTOTAL); }},
22087
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
8 { "Tiles", ID_TILES, [&](){ return readtiles(f, newtilebuf, &tempheader, tempheader.zelda_version, tempheader.build, 0, NEWMAXTILES, false); }},
22088
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
8 { "Tunes", ID_MIDIS, [&](){ return readtunes(f, &tempheader, tunes); }},
22089
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
8 { "Cheat Codes", ID_CHEATS, [&](){ return readcheatcodes(f, &tempheader); }},
22090
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
8 { "Init. Data", ID_INITDATA, [&](){ return readinitdata(f, &tempheader); }},
22091
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
8 { "Custom Player Sprite Data", ID_HEROSPRITES, [&](){ return readherosprites2(f, -1, 0); }},
22092
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
8 { "Up Default Item Drop Sets", ID_ITEMDROPSETS, [&](){ return readitemdropsets(f, -1, 0); }},
22093 };
22094
22095 4 legacy_skip_flags = skip_flags;
22096
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 68 times.
208 for (auto& [desc, section_id, fn] : hardcoded_sections)
22097 {
22098
1/2
✓ Branch 0 taken 68 times.
✗ Branch 1 not taken.
68 int section_enum = section_id_to_enum(section_id);
22099
2/4
✓ Branch 0 taken 68 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 68 times.
✗ Branch 3 not taken.
68 bool skip = section_enum >= 0 && get_bit(skip_flags, section_enum);
22100
1/2
✓ Branch 0 taken 68 times.
✗ Branch 1 not taken.
68 if (skip)
22101 {
22102 // Nothing to read.
22103 if (section_id == ID_RULES)
22104 continue;
22105 if (section_id == ID_GUYS)
22106 continue;
22107
22108 // Haven't looked at how to skip these, because we don't need to currently: the only
22109 // usage of skip_flags currently is all off except: header and tiles (see `load_imagebuf`).
22110 if (section_id == ID_MIDIS)
22111 continue;
22112 if (section_id == ID_CHEATS)
22113 continue;
22114 if (section_id == ID_INITDATA)
22115 continue;
22116 if (section_id == ID_HEROSPRITES)
22117 continue;
22118 if (section_id == ID_ITEMDROPSETS)
22119 continue;
22120 }
22121
22122 // Would be nice, but old sections mostly did not save section sizes. We could advance by
22123 // a specific amount, but it'd be a lot of work to get it right. So, for old quests, let's just
22124 // read all the sections even if requested to skip some.
22125 // if (int retval = maybe_skip_section(f, section_id, skip_flags); retval != qe_OK)
22126 // {
22127 // if (retval == qe_cancel)
22128 // continue;
22129 // checkstatus(retval);
22130 // }
22131
22132
3/6
✓ Branch 0 taken 68 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 68 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 68 times.
✗ Branch 5 not taken.
136 box_out(fmt::format("Reading {}...", desc).c_str());
22133
1/2
✓ Branch 0 taken 68 times.
✗ Branch 1 not taken.
68 ret = fn();
22134
1/9
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 68 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
68 checkstatus(ret);
22135
1/2
✓ Branch 0 taken 68 times.
✗ Branch 1 not taken.
68 box_out("okay.");
22136
1/2
✓ Branch 0 taken 68 times.
✗ Branch 1 not taken.
68 box_eol();
22137 }
22138 4 legacy_skip_flags = nullptr;
22139
22140
2/4
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
✗ Branch 3 not taken.
4 if(!get_bit(skip_flags, skip_subscreens))
22141 {
22142
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 setupsubscreens();
22143
22144
2/2
✓ Branch 0 taken 2048 times.
✓ Branch 1 taken 4 times.
2052 for(int32_t i=0; i<MAXDMAPS; ++i)
22145 {
22146 2048 int32_t type=DMaps[i].type&dmfTYPE;
22147
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 2036 times.
2048 DMaps[i].active_subscreen=(type == dmOVERW || type == dmBSOVERW)?0:1;
22148
1/2
✓ Branch 0 taken 2048 times.
✗ Branch 1 not taken.
2048 DMaps[i].passive_subscreen=(get_qr(qr_ENABLEMAGIC))?0:1;
22149 2048 }
22150 4 }
22151
22152
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 box_out("Setting Up Default Sound Effects...");
22153
22154
2/4
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 4 times.
4 if(!get_bit(skip_flags, skip_sfx))
22155 4 setupsfx();
22156
22157
2/4
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 4 times.
4 if(!get_bit(skip_flags, skip_favorites))
22158 4 init_favorites();
22159
22160
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 box_out("okay.");
22161
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 box_eol();
22162
1/3
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
4 }
22163
22164 128 init_spritelists();
22165
22166 // check data
22167
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 128 times.
128 if(f)
22168 {
22169 128 pack_fclose(f);
22170 128 }
22171 128 clear_quest_tmpfile();
22172
22173
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 128 times.
128 if(!oldquest)
22174 {
22175
1/2
✓ Branch 0 taken 128 times.
✗ Branch 1 not taken.
128 if(exists(tmpfilename))
22176 {
22177 delete_file(tmpfilename);
22178 }
22179 128 }
22180
22181
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 128 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
128 if(fixffcs && combosread && mapsread)
22182 {
22183 for(int32_t i=0; i<map_count; i++)
22184 {
22185 for(int32_t j=0; j<MAPSCRS; j++)
22186 {
22187 for(int32_t m=0; m<32; m++)
22188 {
22189 if(combobuf[TheMaps[(i*MAPSCRS)+j].ffcs[m].data].type == cCHANGE)
22190 TheMaps[(i*MAPSCRS)+j].ffcs[m].flags|=ffCHANGER;
22191 }
22192 }
22193 }
22194 }
22195
22196
4/6
✓ Branch 0 taken 29 times.
✓ Branch 1 taken 99 times.
✓ Branch 2 taken 29 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 29 times.
✗ Branch 5 not taken.
128 if(get_qr(qr_CONTFULL_DEP) && !get_bit(skip_flags, skip_rules) && !get_bit(skip_flags, skip_initdata))
22197 {
22198 29 set_qr(qr_CONTFULL_DEP, 0);
22199 29 zinit.flags.set(INIT_FL_CONTPERCENT,true);
22200 29 zinit.cont_heart=100;
22201 29 zinit.counter[crLIFE]=zinit.mcounter[crLIFE];
22202 29 }
22203
22204 128 box_out("Done.");
22205 128 box_eol();
22206 128 box_end(false);
22207
22208
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 128 times.
128 if(!get_bit(skip_flags, skip_header))
22209 {
22210 128 memcpy(Header, &tempheader, sizeof(tempheader));
22211 128 }
22212
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 128 times.
128 if(!get_bit(skip_flags, skip_zinfo))
22213 {
22214 128 ZI.copyFrom(tempzi);
22215 128 }
22216
22217
1/2
✓ Branch 0 taken 128 times.
✗ Branch 1 not taken.
128 if(get_bit(skip_flags, skip_maps))
22218 {
22219 map_count=old_map_count;
22220 }
22221
22222
1/2
✓ Branch 0 taken 128 times.
✗ Branch 1 not taken.
128 if(get_bit(skip_flags, skip_rules))
22223 {
22224 memcpy(quest_rules, old_quest_rules, QUESTRULES_NEW_SIZE);
22225 memcpy(extra_rules, old_extra_rules, EXTRARULES_SIZE);
22226 }
22227
22228
1/2
✓ Branch 0 taken 128 times.
✗ Branch 1 not taken.
128 if(get_bit(skip_flags, skip_midis))
22229 {
22230 memcpy(midi_flags, old_midi_flags, MIDIFLAGS_SIZE);
22231 }
22232
22233
2/2
✓ Branch 0 taken 124 times.
✓ Branch 1 taken 4 times.
128 if( FFCore.quest_format[vZelda] < 0x210 )
22234 {
22235 4 zprint2("\n[ZQUEST CREATOR METADATA]\n");
22236
22237
1/13
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 4 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
4 switch(FFCore.quest_format[vZelda])
22238 {
22239 case 0x193:
22240 {
22241 zprint2("Last saved in ZC Editor Version: 1.93, Beta %d\n", FFCore.quest_format[vBuild]); break;
22242 }
22243 case 0x192:
22244 {
22245 zprint2("Last saved in ZC Editor Version: 1.92, Beta %d\n", FFCore.quest_format[vBuild]); break;
22246 }
22247 case 0x190:
22248 {
22249 4 zprint2("Last saved in ZC Editor Version: 1.90");
22250
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if ( FFCore.quest_format[vBuild] ) zprint2(", Beta/Build %d\n", FFCore.quest_format[vBuild]);
22251 4 else zprint2("\n");
22252 4 break;
22253 }
22254 case 0x188:
22255 {
22256 zprint2("Last saved in ZC Editor Version: 1.88");
22257 if ( FFCore.quest_format[vBuild] ) zprint2(", Beta/Build %d\n", FFCore.quest_format[vBuild]);
22258 else zprint2("\n");
22259 break;
22260 }
22261 case 0x187:
22262 {
22263 zprint2("Last saved in ZC Editor Version: 1.87");
22264 if ( FFCore.quest_format[vBuild] ) zprint2(", Beta/Build %d\n", FFCore.quest_format[vBuild]);
22265 else zprint2("\n");
22266 break;
22267 }
22268 case 0x186:
22269 {
22270 zprint2("Last saved in ZC Editor Version: 1.86");
22271 if ( FFCore.quest_format[vBuild] ) zprint2(", Beta/Build %d\n", FFCore.quest_format[vBuild]);
22272 else zprint2("\n");
22273 break;
22274 }
22275 case 0x185:
22276 {
22277 zprint2("Last saved in ZC Editor Version: 1.85");
22278 if ( FFCore.quest_format[vBuild] ) zprint2(", Beta/Build %d\n", FFCore.quest_format[vBuild]);
22279 else zprint2("\n");
22280 break;
22281 }
22282 case 0x184:
22283 {
22284 zprint2("Last saved in ZC Editor Version: 1.84");
22285 if ( FFCore.quest_format[vBuild] ) zprint2(", Beta/Build %d\n", FFCore.quest_format[vBuild]);
22286 else zprint2("\n");
22287 break;
22288 }
22289 case 0x183:
22290 {
22291 zprint2("Last saved in ZC Editor Version: 1.83");
22292 if ( FFCore.quest_format[vBuild] ) zprint2(", Beta/Build %d\n", FFCore.quest_format[vBuild]);
22293 else zprint2("\n");
22294 break;
22295 }
22296 case 0x182:
22297 {
22298 zprint2("Last saved in ZC Editor Version: 1.82");
22299 if ( FFCore.quest_format[vBuild] ) zprint2(", Beta/Build %d\n", FFCore.quest_format[vBuild]);
22300 else zprint2("\n");
22301 break;
22302 }
22303 case 0x181:
22304 {
22305 zprint2("Last saved in ZC Editor Version: 1.81");
22306 if ( FFCore.quest_format[vBuild] ) zprint2(", Beta/Build %d\n", FFCore.quest_format[vBuild]);
22307 else zprint2("\n");
22308 break;
22309 }
22310 case 0x180:
22311 {
22312 zprint2("Last saved in ZC Editor Version: 1.80");
22313 if ( FFCore.quest_format[vBuild] ) zprint2(", Beta/Build %d\n", FFCore.quest_format[vBuild]);
22314 else zprint2("\n");
22315 break;
22316 }
22317 default:
22318 {
22319 zprint2("Last saved in ZC Editor Version: %x, Beta %d\n", FFCore.quest_format[vZelda],FFCore.quest_format[vBuild]); break;
22320 }
22321 }
22322 4 }
22323
22324
1/2
✓ Branch 0 taken 128 times.
✗ Branch 1 not taken.
128 if(loading_tileset_flags & TILESET_CLEARMAPS)
22325 {
22326 TheMaps.clear();
22327 TheMaps.resize(MAPSCRS*1);
22328 map_count = 1;
22329 map_autolayers.clear();
22330 map_autolayers.resize(6*1);
22331 for(size_t i = 0; i < MAPSCRS; ++i)
22332 {
22333 TheMaps[i].zero_memory();
22334 }
22335 }
22336
1/2
✓ Branch 0 taken 128 times.
✗ Branch 1 not taken.
128 if(loading_tileset_flags & TILESET_CLEARHEADER)
22337 {
22338 memset(Header->password, 0, sizeof(Header->password));
22339 memset(Header->minver, 0, sizeof(Header->minver));
22340 memset(Header->title, 0, sizeof(Header->title));
22341 memset(Header->author, 0, sizeof(Header->author));
22342 memset(Header->version, 0, sizeof(Header->version));
22343 Header->use_keyfile = 0;
22344 Header->dirty_password = false;
22345 cvs_MD5Context ctx;
22346 cvs_MD5Init(&ctx);
22347 cvs_MD5Update(&ctx, (const uint8_t*)"", 0);
22348 cvs_MD5Final(Header->pwd_hash, &ctx);
22349 }
22350
22351 128 return qe_OK;
22352
22353 invalid:
22354 box_out("error.");
22355 box_eol();
22356 box_end(true);
22357
22358 if(f)
22359 {
22360 pack_fclose(f);
22361 }
22362
22363 if(!oldquest)
22364 {
22365 if(exists(tmpfilename))
22366 {
22367 delete_file(tmpfilename);
22368 }
22369 }
22370
22371 return qe_invalid;
22372
22373 128 }
22374
22375 static bool _is_loading_quest;
22376
22377 bool is_loading_quest()
22378 {
22379 return _is_loading_quest;
22380 }
22381
22382 128 int32_t loadquest(const char *filename, zquestheader *Header, miscQdata *Misc,
22383 zctune *tunes, bool show_progress, byte *skip_flags, byte printmetadata,
22384 bool report, byte qst_num, dword tilesetflags)
22385 {
22386 128 loading_tileset_flags = tilesetflags;
22387 128 const char* basename = get_filename(filename);
22388 128 zapp_reporting_add_breadcrumb("load_quest", basename);
22389 128 zapp_reporting_set_tag("qst.filename", basename);
22390
22391 128 loading_qst_name = filename;
22392 128 loading_qst_num = qst_num;
22393 // In CI, builds are cached for replay tests, which can result in their build dates being earlier than what it would be locally.
22394 // So to avoid a more-recently updated .qst file from hitting the "last saved in a newer version" prompt, we disable in CI.
22395
1/2
✓ Branch 0 taken 128 times.
✗ Branch 1 not taken.
128 if (!is_ci())
22396 loadquest_report = report;
22397
22398 128 _is_loading_quest = true;
22399 128 auto start = std::chrono::steady_clock::now();
22400 128 int32_t ret = _lq_int(filename, Header, Misc, tunes, show_progress, skip_flags, printmetadata);
22401 128 int32_t load_ms = std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::steady_clock::now() - start).count();
22402 128 zprint2("Time to load qst: %d ms\n", load_ms);
22403 128 _is_loading_quest = false;
22404
22405
1/2
✓ Branch 0 taken 128 times.
✗ Branch 1 not taken.
128 if(show_progress)
22406 {
22407 if(ret)
22408 {
22409 box_out("-- Error loading quest file! --");
22410 box_end(true);
22411 }
22412 else box_end(false);
22413 }
22414
22415 128 load_tmp_zi = NULL;
22416 128 loading_qst_name = NULL;
22417 128 loadquest_report = false;
22418 128 loading_qst_num = 0;
22419
22420 128 zapp_reporting_set_tag("qst.title", Header->title);
22421 128 zapp_reporting_set_tag("qst.zc_version", Header->getVerStr());
22422
22423 128 return ret;
22424 }
22425